add escape

This commit is contained in:
zhw2590582 committed 2020-03-22 07:28:36 +08:00
1 parent e2193c7aa9
commit 43f68a3b68
4 files changed
+31 -5

No files matched your search

+14 -2
View File
@@ -673,6 +673,17 @@
var sec = Math.floor(second - hour * 3600 - min * 60);
return (hour > 0 ? [hour, min, sec] : [min, sec]).map(add0).join(':');
}
function escape(str) {
return str.replace(/[&<>'"]/g, function (tag) {
return {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
"'": '&#39;',
'"': '&quot;'
}[tag] || tag;
});
}
@@ -706,7 +717,8 @@
debounce: debounce,
throttle: throttle,
clamp: clamp,
secondToTime: secondToTime
secondToTime: secondToTime,
escape: escape
});
function validElement(value, type, paths) {
@@ -3275,7 +3287,7 @@
if (this.activeCue) {
$subtitle.innerHTML = this.activeCue.text.split(/\r?\n/).map(function (item) {
return "<p>".concat(item, "</p>");
return "<p>".concat(escape(item), "</p>");
}).join('');
this.art.emit('subtitle:update', this.activeCue.text);
}