From 59162b46d99ad48e478721f22d89460715b3cb4a Mon Sep 17 00:00:00 2001 From: Enson Choy <ensonchoy@gmail.com> Date: Fri, 27 Sep 2024 13:21:28 -0700 Subject: [PATCH] fix: EXT-X-KEY: METHOD=NONE parsing error --- src/playlist.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/playlist.rs b/src/playlist.rs index 8b3fa0c..30d36df 100644 --- a/src/playlist.rs +++ b/src/playlist.rs @@ -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); + } }