A prerequisite to this bug is to fix the bug described in #35.
When the entities object is correctly passed to the WebVTTCueTextParser on line 177 as described in the issue above, there are some problems with parsing escape entities.
Steps to Reproduce
const { parse } = new WebVTTParser({
"&": "&",
"&": "&",
"&": "&",
"&": "&",
});
const text1 = `
WEBVTT
1
00:11:46.140 --> 00:11:48.380
Texas A&M`
const text2 = `
WEBVTT
1
00:11:46.140 --> 00:11:48.380
Texas A&`
const text3 = `
WEBVTT
1
00:11:46.140 --> 00:11:48.380
Texas A&M`
const parsed1 = parse(text1, "metadata");
console.log(parsed1.cues[0].tree.children[0].value); // Texas A&M (correctly parsed)
const parsed2 = parse(text2, "metadata");
console.log(parsed2.cues[0].tree.children[0].value); // Texas A& (correctly parsed)
const parsed3 = parse(text3, "metadata");
console.log(parsed3.cues[0].tree.children[0].value); // Texas A&M (incorrectly parsed)
As you can see if the escape characters & are not followed by ; or the end of the string (undefined) but instead followed by another alphanumeric character, the escape characters are not properly parsed.
Solution
I believe some conditional logic needs to be updated or added in lines 632-670 to account for escape entities that are followed by an alphanumeric character.
A prerequisite to this bug is to fix the bug described in #35.
When the entities object is correctly passed to the WebVTTCueTextParser on line 177 as described in the issue above, there are some problems with parsing escape entities.
Steps to Reproduce
As you can see if the escape characters
&are not followed by;or the end of the string (undefined) but instead followed by another alphanumeric character, the escape characters are not properly parsed.Solution
I believe some conditional logic needs to be updated or added in lines 632-670 to account for escape entities that are followed by an alphanumeric character.