e1e725cd by David LaPalomento

TXXX value fields are null-terminated in practice

Two tools used to inject TXXX frames terminate the value field with a null byte. Make sure that isn't included in the parsed representation.
1 parent 95aa0508
......@@ -37,7 +37,8 @@
if (tag.data[i] === 0) {
// parse the text fields
tag.description = parseUtf8(tag.data, 1, i);
tag.value = parseUtf8(tag.data, i + 1, tag.data.length);
// do not include the null terminator in the tag value
tag.value = parseUtf8(tag.data, i + 1, tag.data.length - 1);
break;
}
}
......
......@@ -201,7 +201,7 @@
data: new Uint8Array(id3Tag(id3Frame('TXXX',
0x03, // utf-8
stringToCString('get done'),
stringToInts('{ "key": "value" }')),
stringToCString('{ "key": "value" }')),
[0x00, 0x00]))
});
......@@ -209,7 +209,7 @@
equal(events[0].frames.length, 1, 'parsed one frame');
equal(events[0].frames[0].id, 'TXXX', 'parsed the frame id');
equal(events[0].frames[0].description, 'get done', 'parsed the description');
equal(events[0].frames[0].value, '{ "key": "value" }', 'parsed the value');
deepEqual(JSON.parse(events[0].frames[0].value), { key: 'value' }, 'parsed the value');
});
test('parses WXXX frames', function() {
......@@ -253,7 +253,7 @@
data: new Uint8Array(id3Tag(id3Frame('TXXX',
0x03, // utf-8
stringToCString(''),
stringToInts(value)),
stringToCString(value)),
[0x00, 0x00]))
});
......