Skip to content

Node.js based forum software built for the modern web

fix: only load templates from templates folder

Barış Soner Uşaklıc17452e77d5c
diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js
index 096785177d..3741329c37 100644
--- a/public/src/ajaxify.js
+++ b/public/src/ajaxify.js
@@ -486,6 +486,12 @@ ajaxify.widgets = { render: render };
};
ajaxify.loadTemplate = function (template, callback) {
+ const base = new URL(`${config.asset_base_url}/templates/`, window.location.origin);
+ const url = new URL(`${template}.js`, base);
+ if (!url.pathname.startsWith(base.pathname)) {
+ callback(new Error('[[error:invalid-template-path]]'));
+ return;
+ }
$.ajax({
url: `${config.asset_base_url}/templates/${template}.js`,
cache: false,