15886191 by makoto_kw

Support EXT-X-KEY:IV prefixed with 0X

1 parent 6fe9fa2f
...@@ -280,7 +280,7 @@ export default class ParseStream extends Stream { ...@@ -280,7 +280,7 @@ export default class ParseStream extends Stream {
280 event.attributes = parseAttributes(match[1]); 280 event.attributes = parseAttributes(match[1]);
281 // parse the IV string into a Uint32Array 281 // parse the IV string into a Uint32Array
282 if (event.attributes.IV) { 282 if (event.attributes.IV) {
283 if (event.attributes.IV.substring(0, 2) === '0x') { 283 if (event.attributes.IV.substring(0, 2).toLowerCase() === '0x') {
284 event.attributes.IV = event.attributes.IV.substring(2); 284 event.attributes.IV = event.attributes.IV.substring(2);
285 } 285 }
286 286
......
...@@ -608,6 +608,35 @@ QUnit.test('parses lightly-broken #EXT-X-KEY tags', function() { ...@@ -608,6 +608,35 @@ QUnit.test('parses lightly-broken #EXT-X-KEY tags', function() {
608 'trims and removes quotes around the URI'); 608 'trims and removes quotes around the URI');
609 }); 609 });
610 610
611 QUnit.test('parses prefixed with 0x or 0X #EXT-X-KEY:IV tags', function() {
612 let manifest;
613 let element;
614
615 this.parseStream.on('data', function(elem) {
616 element = elem;
617 });
618
619 manifest = '#EXT-X-KEY:IV=0x1234567890abcdef1234567890abcdef\n';
620 this.lineStream.push(manifest);
621 QUnit.ok(element.attributes.IV, 'detected an IV attribute');
622 QUnit.deepEqual(element.attributes.IV, new Uint32Array([
623 0x12345678,
624 0x90abcdef,
625 0x12345678,
626 0x90abcdef
627 ]), 'parsed an IV value with 0x');
628
629 manifest = '#EXT-X-KEY:IV=0X1234567890abcdef1234567890abcdef\n';
630 this.lineStream.push(manifest);
631 QUnit.ok(element.attributes.IV, 'detected an IV attribute');
632 QUnit.deepEqual(element.attributes.IV, new Uint32Array([
633 0x12345678,
634 0x90abcdef,
635 0x12345678,
636 0x90abcdef
637 ]), 'parsed an IV value with 0X');
638 });
639
611 QUnit.test('ignores empty lines', function() { 640 QUnit.test('ignores empty lines', function() {
612 let manifest = '\n'; 641 let manifest = '\n';
613 let event = false; 642 let event = false;
......