Skip to content

Commit 65e9d8f

Browse files
author
bcupac
authored
fix: Display captions with forward slashes (#3556)
Closes #3555 .
1 parent db8ad31 commit 65e9d8f

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/text/vtt_text_parser.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,9 @@ shaka.text.VttTextParser = class {
436436
}
437437
const tagEnd = payload.substring(i + 1, end);
438438
const tagStart = names.pop();
439-
if (tagStart === tagEnd) {
439+
if (!tagEnd || !tagStart) {
440+
return payload;
441+
} else if (tagStart === tagEnd) {
440442
newPayload += '/' + tagEnd + '>';
441443
i += tagEnd.length + 1;
442444
} else {

test/text/vtt_text_parser_unit.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,18 @@ describe('VttTextParser', () => {
924924
payload: '<c.lime><b>Parse fail 2</c></b>',
925925
nestedCues: [],
926926
},
927+
{
928+
startTime: 100,
929+
endTime: 110,
930+
payload: '<c.lime>forward slash 1/2 in text</c>',
931+
nestedCues: [],
932+
},
933+
{
934+
startTime: 110,
935+
endTime: 120,
936+
payload: '<c.lime>less or more < > in text</c>',
937+
nestedCues: [],
938+
},
927939
],
928940
'WEBVTT\n\n' +
929941
'00:00:20.000 --> 00:00:40.000\n' +
@@ -939,7 +951,11 @@ describe('VttTextParser', () => {
939951
'00:01:20.000 --> 00:01:30.000\n' +
940952
'<b><c.lime>Parse fail 1</b></c>\n\n' +
941953
'00:01:30.000 --> 00:01:40.000\n' +
942-
'<c.lime><b>Parse fail 2</c></b>',
954+
'<c.lime><b>Parse fail 2</c></b>\n\n' +
955+
'00:01:40.000 --> 00:01:50.000\n' +
956+
'<c.lime>forward slash 1/2 in text</c>\n\n' +
957+
'00:01:50.000 --> 00:02:00.000\n' +
958+
'<c.lime>less or more < > in text</c>',
943959
{periodStart: 0, segmentStart: 0, segmentEnd: 0});
944960
});
945961

0 commit comments

Comments
 (0)