Skip to content

Commit a4cb56c

Browse files
committed
fix: Reject non-string locale values in getLocale
Add guard to reject non-string locale values (e.g. arrays from query string parsing) before the regex validation check.
1 parent 088c0e2 commit a4cb56c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Routers/PagesRouter.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,9 @@ export class PagesRouter extends PromiseRouter {
549549

550550
// Validate locale format to prevent path traversal; only allow
551551
// standard locale patterns like "en", "en-US", "de-AT", "zh-Hans-CN"
552+
if (locale !== undefined && typeof locale !== 'string') {
553+
return undefined;
554+
}
552555
if (typeof locale === 'string' && !/^[a-zA-Z]{2,3}(-[a-zA-Z0-9]{2,8})*$/.test(locale)) {
553556
return undefined;
554557
}

0 commit comments

Comments
 (0)