Skip to content

Commit 15ffd10

Browse files
committed
Fix CodeQL string escape issue
1 parent 7297c15 commit 15ffd10

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

webgui-new/scripts/patch-basepath.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ const NEW_BASE = process.env.APP_BASE_PATH || '/new';
55

66
console.log(`[patch-basepath] ${PLACEHOLDER} -> ${NEW_BASE}`);
77

8+
function escapeRegExp(s) {
9+
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
10+
}
11+
812
try {
913
const results = replaceInFileSync({
1014
files: ['out/**/*.html', 'out/**/*.js', 'out/**/*.json'],
11-
from: new RegExp(PLACEHOLDER.replace(/\//g, '\\/'), 'g'),
12-
to: NEW_BASE,
15+
from: new RegExp(escapeRegExp(PLACEHOLDER), 'g'),
16+
to: () => NEW_BASE,
1317
});
1418
console.log('[patch-basepath] modified files:', results.length);
1519
} catch (err) {

0 commit comments

Comments
 (0)