commit - 18185121cc63011d9f097754c13cdc4cc11fd72b
commit + a2109c70b8c1180b4a6b9400e503e37ff4abdda8
blob - 20dcbafb6a363bd6b7450c989e8750e388189460
blob + 0117911d561fd529fde1dada7019c2b885925615
--- m3u8/parse.go
+++ m3u8/parse.go
v.Codecs = strings.Split(strings.Trim(it.val, `"`), ",")
case "RESOLUTION":
it = <-items
- if it.typ != itemString {
- return nil, fmt.Errorf("parse resolution attribute: unexpected %s", it)
- }
res, err := parseResolution(it.val)
if err != nil {
return nil, fmt.Errorf("parse resolution: %w", err)
case "CLOSED-CAPTIONS":
it = <-items
if it.typ != itemString {
- return nil, fmt.Errorf("parse closed-captions: unexpcted %s", it)
+ return nil, fmt.Errorf("parse closed-captions: unexpected %s", it)
}
v.ClosedCaptions = strings.Trim(it.val, `"`)
default:
return &v, nil
}
}
- fmt.Println(v)
return &v, nil
}
if err != nil {
return res, fmt.Errorf("vertical pixels: %v", err)
}
+ if res[0] < 0 || res[1] < 0 {
+ return res, fmt.Errorf("negative dimensions")
+ }
return res, nil
}
blob - 8614b5d3dff6b87a4b67ccf09b7e89a9543f3348
blob + 96e924816a03c74379ff972dad1afc1f44551989
--- m3u8/parse_test.go
+++ m3u8/parse_test.go
t.Errorf("want %d, got %d", 91240, plist.Sequence)
}
}
+
+func TestResolution(t *testing.T) {
+ var tests = []struct {
+ name string
+ s string
+ }{
+ {"double x", "1280xx720"},
+ {"missing x", "1280720"},
+ {"missing height", "1280x"},
+ {"negative", "-1x-1"},
+ {"decimal", "10.69x20"},
+ }
+
+ for _, tt := range tests {
+ _, err := parseResolution(tt.s)
+ if err == nil {
+ t.Errorf("parse resolution %q (%s): no error", tt.s, tt.name)
+ continue
+ }
+ }
+}