aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/core-utils/renderer
diff options
context:
space:
mode:
authorThavarasa Prasanth <45243326+pthavarasa@users.noreply.github.com>2021-03-31 08:32:05 +0200
committerGitHub <noreply@github.com>2021-03-31 08:32:05 +0200
commit4097c6d66cb2919c28b5bce44b259e630923fbe0 (patch)
treed57897b0b8762202a0be90388e9a79153690b9d9 /shared/core-utils/renderer
parent47099aba46be7757d833422f1706b99a3c0e28ea (diff)
downloadPeerTube-4097c6d66cb2919c28b5bce44b259e630923fbe0.tar.gz
PeerTube-4097c6d66cb2919c28b5bce44b259e630923fbe0.tar.zst
PeerTube-4097c6d66cb2919c28b5bce44b259e630923fbe0.zip
fix missing title attribute on <iframe> tag suggested for embedding (#3901)
* title attribute is missing on <iframe> tag suggested for embedding #3861 * fix #3901 * fix: escapeHTML #3901 * fix: playlist title instead of video title #3901 * fix #3901 * assign title directly #3901
Diffstat (limited to 'shared/core-utils/renderer')
-rw-r--r--shared/core-utils/renderer/html.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/shared/core-utils/renderer/html.ts b/shared/core-utils/renderer/html.ts
index 1220848a0..de4ad47ac 100644
--- a/shared/core-utils/renderer/html.ts
+++ b/shared/core-utils/renderer/html.ts
@@ -19,3 +19,21 @@ export const SANITIZE_OPTIONS = {
19 } 19 }
20 } 20 }
21} 21}
22
23// Thanks: https://stackoverflow.com/a/12034334
24export function escapeHTML (stringParam: string) {
25 if (!stringParam) return ''
26
27 const entityMap = {
28 '&': '&amp;',
29 '<': '&lt;',
30 '>': '&gt;',
31 '"': '&quot;',
32 '\'': '&#39;',
33 '/': '&#x2F;',
34 '`': '&#x60;',
35 '=': '&#x3D;'
36 }
37
38 return String(stringParam).replace(/[&<>"'`=/]/g, s => entityMap[s])
39}