fix(layout): escape every bracket and paren in footer package links

String replace() only replaced the first `[`, `]`, `(` and `)`, and link
text backslashes were left as is. Use global regexes and escape
backslashes too.

Fixes CodeQL js/incomplete-sanitization alerts in the tool layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sebastian DanielssonandClaude Opus 5.5 authored and sharevb committed 2026-10-03 21:11:50 +02:00
1 parent f1b20c7c18
commit d785329e74
1 file changed
+1 -1
+1 -1
View File
@@ -62,7 +62,7 @@ const toolTitle = computed<string>(() => t(`tools.${i18nKey.value}.title`, Strin
const toolDescription = computed<string>(() => t(`tools.${i18nKey.value}.description`, String(route.meta.description)));
const toolFooter = computed<string>(() => {
const createLink = (linkText: string, url: string) => {
return `[${linkText.replace('[', '\\[').replace(']', '\\]')}](${url.replace('(', '%28').replace(')', '%29')})`;
return `[${linkText.replace(/[\\[\]]/g, '\\$&')}](${url.replace(/\(/g, '%28').replace(/\)/g, '%29')})`;
};
let footer = t(`tools.${i18nKey.value}.footer`, String(route.meta.footer));
if (footer === 'undefined') {