Check url.Parse error

This commit is contained in:
Alex Ballas
2022-09-05 22:46:55 +03:00
parent b612dccd94
commit 66ee7bb299
2 changed files with 10 additions and 6 deletions

View File

@@ -102,11 +102,14 @@ func (p *NewScreen) InterInit(tv *soapcalls.TVPayload, c chan error) {
}()
p.mu.Lock()
p.mediaTitle = tv.MediaURL
mediaTitlefromURL, err := url.Parse(tv.MediaURL)
if err == nil {
p.mediaTitle = strings.TrimLeft(mediaTitlefromURL.Path, "/")
if err != nil {
c <- fmt.Errorf("interactive screen error: %w", err)
return
}
p.mediaTitle = strings.TrimLeft(mediaTitlefromURL.Path, "/")
p.mu.Unlock()
encoding.Register()

View File

@@ -250,12 +250,13 @@ func setAVTransportSoapBuild(mediaURL, mediaType, subtitleURL string, transcode,
class = "object.item.videoItem.movie"
}
mediaTitle := mediaURL
mediaTitlefromURL, err := url.Parse(mediaURL)
if err == nil {
mediaTitle = strings.TrimLeft(mediaTitlefromURL.Path, "/")
if err != nil {
return nil, fmt.Errorf("setAVTransportSoapBuild url parse error: %w", err)
}
mediaTitle := strings.TrimLeft(mediaTitlefromURL.Path, "/")
re, err := regexp.Compile(`[&<>\\]+`)
if err != nil {
return nil, fmt.Errorf("setAVTransportSoapBuild regex compile error: %w", err)