Skip to content

Commit

Permalink
fix: Display captions with forward slashes (#3556)
Browse files Browse the repository at this point in the history
Closes #3555 .
  • Loading branch information
bcupac committed Aug 16, 2021
1 parent db8ad31 commit 65e9d8f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/text/vtt_text_parser.js
Expand Up @@ -436,7 +436,9 @@ shaka.text.VttTextParser = class {
}
const tagEnd = payload.substring(i + 1, end);
const tagStart = names.pop();
if (tagStart === tagEnd) {
if (!tagEnd || !tagStart) {
return payload;
} else if (tagStart === tagEnd) {
newPayload += '/' + tagEnd + '>';
i += tagEnd.length + 1;
} else {
Expand Down
18 changes: 17 additions & 1 deletion test/text/vtt_text_parser_unit.js
Expand Up @@ -924,6 +924,18 @@ describe('VttTextParser', () => {
payload: '<c.lime><b>Parse fail 2</c></b>',
nestedCues: [],
},
{
startTime: 100,
endTime: 110,
payload: '<c.lime>forward slash 1/2 in text</c>',
nestedCues: [],
},
{
startTime: 110,
endTime: 120,
payload: '<c.lime>less or more < > in text</c>',
nestedCues: [],
},
],
'WEBVTT\n\n' +
'00:00:20.000 --> 00:00:40.000\n' +
Expand All @@ -939,7 +951,11 @@ describe('VttTextParser', () => {
'00:01:20.000 --> 00:01:30.000\n' +
'<b><c.lime>Parse fail 1</b></c>\n\n' +
'00:01:30.000 --> 00:01:40.000\n' +
'<c.lime><b>Parse fail 2</c></b>',
'<c.lime><b>Parse fail 2</c></b>\n\n' +
'00:01:40.000 --> 00:01:50.000\n' +
'<c.lime>forward slash 1/2 in text</c>\n\n' +
'00:01:50.000 --> 00:02:00.000\n' +
'<c.lime>less or more < > in text</c>',
{periodStart: 0, segmentStart: 0, segmentEnd: 0});
});

Expand Down

0 comments on commit 65e9d8f

Please sign in to comment.