Skip to content

A free, self-hostable news aggregator…

Security: apply encodeURIComponent to share template (#9146)

Alexandre Alapetite1b7178a18bef
diff --git a/p/scripts/main.js b/p/scripts/main.js
index a05ff2a5b..243fb819f 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -822,11 +822,11 @@ function show_share_menu(el) {
const title = title_el.textContent;
const titleText = title;
const template = document.getElementById(templateId).innerHTML
- .replace(/--entryId--/g, id)
- .replace(/--link--/g, link)
- .replace(/--titleText--/g, titleText)
- .replace(/--websiteName--/g, websiteName)
- .replace(/--articleAuthors--/g, articleAuthorsText);
+ .replace(/--entryId--/g, encodeURIComponent(id))
+ .replace(/--link--/g, encodeURIComponent(link))
+ .replace(/--titleText--/g, encodeURIComponent(titleText))
+ .replace(/--websiteName--/g, encodeURIComponent(websiteName))
+ .replace(/--articleAuthors--/g, encodeURIComponent(articleAuthorsText));
div.insertAdjacentHTML('beforeend', template);
}