fix: EXT-X-KEY: METHOD=NONE parsing error

This commit is contained in:
Enson Choy 2024-09-27 13:21:28 -07:00
parent 381ac7732f
commit 59162b46d9

View file

@ -976,7 +976,7 @@ impl Key {
let uri = quoted_string!(attrs, "URI");
let iv = unquoted_string!(attrs, "IV");
if method == KeyMethod::None && iv.is_none() {
if method != KeyMethod::None && iv.is_none() {
return Err("IV is required unless METHOD is NONE".parse().unwrap());
}
let keyformat = quoted_string!(attrs, "KEYFORMAT");
@ -1240,4 +1240,17 @@ mod test {
"#EXT-X-CUE-IN"
)
}
#[test]
fn key_none_method_parsing() {
let key = Key::from_hashmap(
vec![("METHOD".into(), QuotedOrUnquoted::Unquoted("NONE".into()))]
.into_iter()
.collect(),
);
assert!(key.is_ok());
let key = key.unwrap();
assert_eq!(key.method, KeyMethod::None);
}
}