Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

XSS hardening

Chocobozzzef8565c26412
diff --git a/client/src/standalone/videos/shared/player-html.ts b/client/src/standalone/videos/shared/player-html.ts
index 8aa127a610..1b554a586d 100644
--- a/client/src/standalone/videos/shared/player-html.ts
+++ b/client/src/standalone/videos/shared/player-html.ts
@@ -42,10 +42,10 @@ export class PlayerHTML {
errorBlock.style.display = 'flex'
const errorTitle = document.getElementById('error-title')
- errorTitle.innerHTML = peertubeTranslate('Sorry', translations)
+ errorTitle.textContent = peertubeTranslate('Sorry', translations)
const errorText = document.getElementById('error-content')
- errorText.innerHTML = translatedText
+ errorText.textContent = translatedText
document.getElementById('error-details').style.display = 'none'
diff --git a/server/core/helpers/custom-validators/misc.ts b/server/core/helpers/custom-validators/misc.ts
index 3b5ae3190e..b44838c0f9 100644
--- a/server/core/helpers/custom-validators/misc.ts
+++ b/server/core/helpers/custom-validators/misc.ts
@@ -120,7 +120,7 @@ export function isFileValid (options: {
}
export function checkMimetypeRegex (fileMimeType: string, mimeTypeRegex: string) {
- return new RegExp(`^${mimeTypeRegex}$`, 'i').test(fileMimeType)
+ return new RegExp(`^(?:${mimeTypeRegex})$`, 'i').test(fileMimeType)
}
// ---------------------------------------------------------------------------
diff --git a/server/core/lib/html/shared/tags-html.ts b/server/core/lib/html/shared/tags-html.ts
index 0a1cbd4ce4..4f7737d624 100644
--- a/server/core/lib/html/shared/tags-html.ts
+++ b/server/core/lib/html/shared/tags-html.ts
@@ -207,7 +207,7 @@ export class TagsHtml {
} else if (embedIndexation) {
tagsStr += `<meta name="robots" content="noindex, indexifembedded" />`
} else if (url) { // SEO, use origin URL
- tagsStr += `<link rel="canonical" href="${url}" />`
+ tagsStr += `<link rel="canonical" href="${escapeAttribute(url)}" />`
}
// RSS