@@ -1396,15 +1396,31 @@ describe('Pages Router', () => {
13961396 expect ( response . text ) . toContain ( '<img' ) ;
13971397 } ) ;
13981398
1399- it ( 'should escape XSS in locale parameter' , async ( ) => {
1399+ it ( 'should reject XSS payload in locale parameter' , async ( ) => {
14001400 const xssLocale = '"><svg/onload=alert(1)>' ;
14011401 const response = await request ( {
14021402 url : `http://localhost:8378/1/apps/choose_password?locale=${ encodeURIComponent ( xssLocale ) } &appId=test` ,
14031403 } ) ;
14041404
14051405 expect ( response . status ) . toBe ( 200 ) ;
1406+ // Invalid locale is rejected by format validation, so the XSS
1407+ // payload never reaches the page content
14061408 expect ( response . text ) . not . toContain ( '<svg/onload=alert(1)>' ) ;
1407- expect ( response . text ) . toContain ( '"><svg' ) ;
1409+ expect ( response . text ) . not . toContain ( '"><svg' ) ;
1410+ } ) ;
1411+
1412+ it ( 'should reject non-ASCII characters in locale parameter' , async ( ) => {
1413+ // Non-ASCII characters like ğ (U+011F) would cause ERR_INVALID_CHAR
1414+ // when set as HTTP header value if not rejected by locale validation
1415+ const nonAsciiLocale = 'ğ' ;
1416+ const response = await request ( {
1417+ url : `http://localhost:8378/1/apps/choose_password?locale=${ encodeURIComponent ( nonAsciiLocale ) } &appId=test` ,
1418+ } ) ;
1419+
1420+ expect ( response . status ) . toBe ( 200 ) ;
1421+ // Non-ASCII locale is rejected by format validation;
1422+ // no ERR_INVALID_CHAR error occurs
1423+ expect ( response . headers [ 'x-parse-page-param-locale' ] ) . toBeUndefined ( ) ;
14081424 } ) ;
14091425
14101426 it ( 'should handle legitimate usernames with quotes correctly' , async ( ) => {
0 commit comments