Skip to content

Commit 49c001f

Browse files
committed
fix(i18n): harden interpolation checker
1 parent 3fa169d commit 49c001f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎scripts/check-i18n-interpolation.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Usage: node scripts/check-i18n-interpolation.js
66
*
7-
* Only calls with a string-literal key and an object-literal second argument are checked.
7+
* Only calls with a string-literal key and no second argument or an object-literal one are checked.
88
* A spread in the object skips the call.
99
*/
1010

@@ -29,6 +29,8 @@ const files = execFileSync(
2929

3030
const resources = {}
3131
function getResource(pkg, ns) {
32+
// A namespace is a locale file name. Reject anything that could leave the locale directory.
33+
if (!/^[\w-]+$/.test(ns)) return undefined
3234
const id = `${pkg}:${ns}`
3335
if (!(id in resources)) {
3436
const file = path.join(ROOT, pkg === "src" ? "src" : "webview-ui/src", "i18n/locales/en", `${ns}.json`)

0 commit comments

Comments
 (0)