Skip to content

Commit 728f734

Browse files
committed
Second attempt
1 parent 043eb18 commit 728f734

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

assets/gulpfile.vue.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function transformVueSfc(source, filePath, vueUrl) {
9999
.replace(/\\/g, '\\\\') // escape backslashes FIRST
100100
.replace(/`/g, '\\`') // then escape backticks
101101
.replace(/\$\{/g, '\\${'); // and escape template literal interpolation
102-
102+
103103
parts.push(`
104104
(function injectStyles() {
105105
const el = document.createElement('style');

web/js/modules/backend/AppearanceEdit.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ export class AppearanceEdit {
4949
}
5050

5151
const parsed = new URL(editLinkDefault.replace(/DEFAULT/, $selected.val()), window.location.origin);
52-
$editLink.attr("href", parsed.pathname + parsed.search);
52+
const path = parsed.pathname + parsed.search;
53+
if (/^\/[a-zA-Z0-9\-_\/?=&.]*$/.test(path)) {
54+
$editLink.attr("href", path);
55+
} else {
56+
console.error("Rejected unsafe redirect path:", path);
57+
}
5358
};
5459
$inputs.on("change", onChange);
5560
onChange();

web/js/modules/backend/MotionList.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ export class MotionList {
9696
link = link.replace("REPLACED", replaced);
9797
link = link.replace("MOTIONTYPES", motionTypes.join(","));
9898
const url = new URL(link, window.location.origin);
99-
$(this).attr("href", url.pathname + url.search);
99+
const path = url.pathname + url.search;
100+
if (/^\/[a-zA-Z0-9\-_\/?=&.]*$/.test(path)) {
101+
$(this).attr("href", path);
102+
} else {
103+
console.error("Rejected unsafe redirect path:", path);
104+
}
100105
});
101106
};
102107
$dd.find("input[type=checkbox]").on("change", recalcLinks).trigger("change");

web/js/modules/shared/SiteCreateWizard.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,13 @@ export class SiteCreateWizard {
313313
$form.find("#panelLanguage input").on("change", function () {
314314
const val = /** @type {string} */ ($form.find("#panelLanguage input:checked").val());
315315
const url = new URL($form.find("#panelLanguage").data("url").replace(/LNG/, val), window.location.origin);
316-
window.location.href = url.pathname + url.search;
316+
const path = url.pathname + url.search;
317+
318+
if (/^\/[a-zA-Z0-9\-_\/?=&.]*$/.test(path)) {
319+
window.location.href = path;
320+
} else {
321+
console.error("Rejected unsafe redirect path:", path);
322+
}
317323
});
318324

319325
// The enter key should not submit the form, but lead to the next panel

0 commit comments

Comments
 (0)