-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specifying the "u" flag to pattern attribute may cause backward compatibility issue #439
Comments
I recognize the problem, but I personally at least think it is OK. Strange regexes now become more lenient, allowing some previously-invalid inputs to be submitted. This is not a big issue; client-side validation is in general easy to bypass, so making it more lenient in edge cases is not cause for concern. Nobody's app will fail to load if this change is made. I think if there is a concern about web authors not figuring out the change, user agents should consider a console log when such SyntaxErrors occur. |
thanks, I agree that this change won't introduce critical issue. then, are those error handling and informative message under the scope of the spec? |
In general dev console messages aren't something the spec mandates, but it might be a good idea to include a non-normative note suggesting it. I can work on that if we're all agreed. |
yeah, having the note in the spec would be nice :) |
Would it be good to also send events when there's a SyntaxError? (error on the input; maybe also send to window.onerror) |
will it specify when to compile the pattern and send the error event? IMO, showing informative console message, that is not visible to the script, is sufficient. |
Probably when the attribute is set or changed, or the element is created with the attribute present. But yeah... |
Closes #439, where we settled on this as a solution to the potential back-compat problem of more patterns failing to compile now that the "u" flag is specified.
Closes #439, where we settled on this as a solution to the potential back-compat problem of more patterns failing to compile now that the "u" flag is specified.
FYI, there has been a backwards compatibility issue now |
Reopening for further consideration. |
@mathiasbynens' comment at http://stackoverflow.com/questions/36953775/firefox-error-unable-to-check-input-because-the-pattern-is-not-a-valid-regexp#comment61507597_36956352
If we assume that we want to support |
See https://bugs.ecmascript.org/show_bug.cgi?id=3157 where it was decided to throw on invalid I’d strongly prefer powering through for now, and helping the affected sites update their code through DevRel. If more breakage comes to light we can still reconsider. |
Support table with links to bugs for both |
It seems people are powering through on shipping this. As predicted any back-compat issues are not actually problematic but are just letting some extra things pass client-side validation. So, re-closing. |
https://html.spec.whatwg.org/multipage/forms.html#the-pattern-attribute
ES6 requires more strict syntax when "u" flag is specified for RegExp (see the difference between [+U] and [~U] there), and it rejects some patterns that was working without "u" flag.
for example, escaping single-quote is disallowed when "u" flag is set, and following case does no pattern matching, because of SyntaxError.
IIUC, the flag for pattern attribute is changed at some point from "", and this may cause backward compatibility issue.
Also, it could be hard to figure out the regression, for web content authors, because the SyntaxError is not reported, according to the spec.
(this is originally reported to https://bugzilla.mozilla.org/show_bug.cgi?id=1227906)
The text was updated successfully, but these errors were encountered: