tdegrunt / jsonschema

JSON Schema validation
Other
1.83k stars 263 forks source link

v1.4.1 does not support chrome 49 #366

Open bingcoder opened 2 years ago

bingcoder commented 2 years ago

v1.4.1 add regexp /^("(?:[!#-[]-\u{10FFFF}]|\[\t -\u{10FFFF}])...$/u not support chrome 49

'idn-email': /^("(?:[!#-\[\]-\u{10FFFF}]|\\[\t -\u{10FFFF}])*"|[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}](?:\.?[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}])*)@([!#-'*+\-/-9=?A-Z\^-\u{10FFFF}](?:\.?[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}])*|\[[!-Z\^-\u{10FFFF}]*\])$/u

Whether to abandon support for Chrome 49?

Thanks

awwright commented 2 years ago

@bingcoder Please provide the error.

Chrome 49 is old, I'm not sure how I would test back that far.

ayonix commented 2 years ago

We have the same problem, but in IE11 (Outlook unfortunately still uses IE to render add-ins in many configurations).

The error is just SyntaxError in regular expression, apparently because IE/the old Chrome don't support /u for regexes. In the IE dev-console /1/u.test("1") has the same error as simple test.

awwright commented 2 years ago

Since this is potentially an easy fix I'll take a look at it... It might be possible to rewrite this so it uses surrogate pairs.

@bingcoder @ayonix If you change it so it reads:

'idn-email': /^("(?:[!#-\[\]-\uFFFF]|\\[\t -\uFFFF])*"|[!#-'*+\-/-9=?A-Z\^-\uFFFF](?:\.?[!#-'*+\-/-9=?A-Z\^-\uFFFF])*)@([!#-'*+\-/-9=?A-Z\^-\uFFFF](?:\.?[!#-'*+\-/-9=?A-Z\^-\uFFFF])*|\[[!-Z\^-\uFFFF]*\])$/

Does that work for you?

ayonix commented 2 years ago

That regex alone seems to work, in 1.4.1 are more issues for IE though. When i replace the regex with yours, the next complaint of it is: SCRIPT5021: Invalid range in character set which seems to be the [~-\u{10FFFF}] in iri-reference. Also there are more /u flags on regexes: iri-reference,uri-template,json-pointer,relative-json-pointer and maybe something else I've missed. Thanks for looking into it :)