mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-12 06:26:16 -08:00
add escape
This commit is contained in:
1 parent
e2193c7aa9
commit
43f68a3b68
4 files changed
+31
-5
No files matched your search
@@ -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 {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
"'": ''',
|
||||
'"': '"'
|
||||
}[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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user