Skip to content

Commit a6ee5f3

Browse files
authored
Merge pull request #1187 from CatoTH/v4-js-fixes
Update Libraries + JS Sanitizing
2 parents 7d0a06a + 1327d60 commit a6ee5f3

9 files changed

Lines changed: 218 additions & 190 deletions

File tree

assets/gulpfile.vue.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ function transformVueSfc(source, filePath, vueUrl) {
9494
});
9595

9696
if (styleChunks.length) {
97-
const allStyles = styleChunks.join('\n').replace(/`/g, '\\`');
97+
const allStyles = styleChunks
98+
.join('\n')
99+
.replace(/\\/g, '\\\\') // escape backslashes FIRST
100+
.replace(/`/g, '\\`') // then escape backticks
101+
.replace(/\$\{/g, '\\${'); // and escape template literal interpolation
102+
98103
parts.push(`
99104
(function injectStyles() {
100105
const el = document.createElement('style');

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@types/typeahead": "^0.11.32",
3030
"autoprefixer": "^10.5.0",
3131
"confusing-browser-globals": "^1.0.11",
32-
"eslint": "^10.4.1",
32+
"eslint": "^10.5.0",
3333
"eslint-plugin-promise": "^7.3.0",
3434
"globals": "^17.6.0",
3535
"gulp": "^5.0.1",
@@ -41,7 +41,7 @@
4141
"gulp-uglify": "^3.0.2",
4242
"pa11y": "^9.1.1",
4343
"postcss": "^8.5.15",
44-
"sass": "^1.100.0"
44+
"sass": "^1.101.0"
4545
},
4646
"directories": {
4747
"bin": "./bin/"
@@ -58,7 +58,7 @@
5858
"isotope-layout": "^3.0.6",
5959
"moment": "^2.30.1",
6060
"requirejs": "^2.3.8",
61-
"rollup": "^4.61.1",
61+
"rollup": "^4.62.0",
6262
"sortablejs": "^1.15.7",
6363
"vue": "^3.5.38",
6464
"vue-draggable-plus": "^0.6.1",

pnpm-lock.yaml

Lines changed: 167 additions & 177 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ allowBuilds:
33
es5-ext: false
44
puppeteer: false
55
minimumReleaseAge: 4320 # 3 Days - a bit more conservative than the default
6+
overrides:
7+
postcss: ^8.5.15

web/js/modules/backend/AppearanceEdit.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ export class AppearanceEdit {
4747
if ($selected.length === 0) {
4848
$selected = $inputs.first();
4949
}
50-
$editLink.attr("href", editLinkDefault.replace(/DEFAULT/, $selected.val()));
50+
51+
const parsed = new URL(editLinkDefault.replace(/DEFAULT/, $selected.val()), window.location.origin);
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+
}
5158
};
5259
$inputs.on("change", onChange);
5360
onChange();

web/js/modules/backend/MotionList.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ export class MotionList {
9595
link = link.replace("INACTIVE", inactive);
9696
link = link.replace("REPLACED", replaced);
9797
link = link.replace("MOTIONTYPES", motionTypes.join(","));
98-
$(this).attr("href", link);
98+
const url = new URL(link, window.location.origin);
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+
}
99105
});
100106
};
101107
$dd.find("input[type=checkbox]").on("change", recalcLinks).trigger("change");

web/js/modules/frontend/MotionMergeAmendments.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -592,10 +592,16 @@ class MotionMergeAmendmentsTextarea {
592592
html = html.replace(new RegExp(ent, 'g'), entities[ent]);
593593
});
594594

595-
return html.replace(/\s+</g, '<').replace(/>\s+/g, '>')
596-
.replace(/<[^>]*ice-ins[^>]*>/g, 'ice-ins') // make sure accepted insertions are still recognized as change
597-
.replace(/<ins[^>]*>/g, 'ice-ins')
598-
.replace(/<[^>]*>/g, '');
595+
let previous;
596+
do {
597+
previous = html;
598+
html = html.replace(/\s+</g, '<').replace(/>\s+/g, '>')
599+
.replace(/<[^>]*ice-ins[^>]*>/g, 'ice-ins') // make sure accepted insertions are still recognized as change
600+
.replace(/<ins[^>]*>/g, 'ice-ins')
601+
.replace(/<[^>]*>/g, '');
602+
} while (html !== previous);
603+
604+
return html;
599605
}
600606

601607
onChanged() {

web/js/modules/installation/InitDb.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@ export class InitDb {
4949
gotoLanguageVariant = () => {
5050
let href = window.location.href.split("?")[0]
5151
href += "?language=" + $("#language").val()
52-
window.location.href = href
52+
const url = new URL(href, window.location.origin);
53+
const path = url.pathname + url.search;
54+
if (/^\/[a-zA-Z0-9\-_/?=&.,]*$/.test(path)) {
55+
window.location.href = path;
56+
} else {
57+
console.error("Rejected unsafe redirect path:", path);
58+
}
5359
}
5460

5561
/**

web/js/modules/shared/SiteCreateWizard.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,14 @@ export class SiteCreateWizard {
312312

313313
$form.find("#panelLanguage input").on("change", function () {
314314
const val = /** @type {string} */ ($form.find("#panelLanguage input:checked").val());
315-
const url = $form.find("#panelLanguage").data("url").replace(/LNG/, val);
316-
window.location.href = url;
315+
const url = new URL($form.find("#panelLanguage").data("url").replace(/LNG/, val), window.location.origin);
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)