You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The non-ASCII characters «»“”‘’ are interpreted differently when the charset is set to Shift_JIS on the HTML page as a response header, and it causes the regular expression not to be closed properly, running into the next lines making a syntax error in the middle of the JSON. The same behavior is seen in Firefox and Chrome, I have not checked Edge.
Proposed solution:
Don't use non-ASCII characters which are unsafe when charsets are changed on the page, instead use a String that will be constructed with escaped characters:
codefactor
changed the title
charset= Shift_JIS will fail to parse URI.js with a syntax error caused by non-ASCII characterscharset=Shift_JIS will fail to parse URI.js with a syntax error caused by non-ASCII characters
Jun 8, 2022
codefactor
changed the title
charset=Shift_JIS will fail to parse URI.js with a syntax error caused by non-ASCII characters
charset=Shift_JIS will fail to parse URI.js with a syntax error caused by non-ASCII characters in RegExp
Jun 8, 2022
As an update - from our side, we have other resources that might require UTF-8 charset, so we will fix this issue from our side by consistently using UTF-8 charset.
However, it still might be a good idea to have the Javascript file to contain ASCII characters only so that this syntax error wouldn't come up if for whatever reason the page gets switched to Japanese charset.
However, this support does objectively increase the size of the file by a few bytes - so it's a little bit of a trade off.
Steps to Reproduce:
content-type: text/html;charset=Shift_JIS
Unfortunately I can't find an easy way to give a link for this easily, but if it's necessary I could produce one maybe with codesandbox.
Expected:
The Javascript include should run, there should be no errors in the console
Actual:
The Javascript fails to parse with an error in the logs:
Root Cause:
There are non-ASCII characters inside of a Regular Expression in a couple places, example:
URI.js/src/URI.js
Line 231 in b655c1b
The non-ASCII characters
«»“”‘’
are interpreted differently when the charset is set toShift_JIS
on the HTML page as a response header, and it causes the regular expression not to be closed properly, running into the next lines making a syntax error in the middle of the JSON. The same behavior is seen in Firefox and Chrome, I have not checked Edge.Proposed solution:
Don't use non-ASCII characters which are unsafe when charsets are changed on the page, instead use a String that will be constructed with escaped characters:
One other place:
URI.js/src/URI.js
Line 238 in b655c1b
Could update to this:
These are 2 places, there might be more.
The text was updated successfully, but these errors were encountered: