This commit is contained in:
Enson Choy 2024-09-27 20:29:36 +00:00 committed by GitHub
commit 1752e8ec34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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);
}
}