Issue metadata
Sign in to add a comment
|
Invalid pattern attribute prevents form submission
Reported by
d...@ssl247.co.uk,
Aug 19 2016
|
||||||||||||||||||||||
Issue description
UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.70 Safari/537.36
Steps to reproduce the problem:
1. create a simple html5 form.
2. add the following
<form>
<input name="name" id="name">
<input name="email" required="required" pattern="^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$" data-validation-type="email" placeholder="Email address" maxlength="100" type="email" id="email">
<button type="submit" name="button" id="button" >Submit</button>
</form>
3. note without other fields works fine
4. submit form
What is the expected behavior?
The regular expression is valid and works in all other browsers.
What went wrong?
Throws this error
Pattern attribute value ^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$ is not a valid regular expression: Uncaught SyntaxError: Invalid regular expression: /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/: Invalid escape
Did this work before? Yes 52.0.2743.116 m
Chrome version: 53.0.2785.70 Channel: beta
OS Version: 10.0
Flash Version: Shockwave Flash 23.0 r0
you can see my js fiddle of it https://jsfiddle.net/o2usqhmn/
,
Aug 19 2016
Thank you, that has resolved the problem. Just out of interest what version of Firefox was it failing on also? That regular expression has been in a production site for several years without issue until we tested it in 53.0.2785.70 .
,
Aug 19 2016
It failed in FireFox 48 for me.
,
Sep 18 2016
The validation behaviour is still incorrect, and not consistent with Firefox 48. Chrome will fail validation if the pattern is incorrect, unless the form is submitted without first de-focusing the input (e.g. press enter) in which case it submits. Here is a simpler test case to demonstrate this: <!DOCTYPE html> <html> <body> <form> <input name="test" pattern="\'"> <button type="submit" name="button" id="button" >Submit</button> </form> </body> </html> In Chrome 53.0.2785.116: Enter any text into the input, press enter: form submits. Enter any text, unfocus the input, submit the form (either by clicking submit, or focusing the input and pressing enter): Please Match Requested Format In Firefox 48: Form submits in both cases with an invalid pattern. Expected: An invalid pattern should be ignored with a warning; form should still submit.
,
Sep 22 2016
@Comment 1: - whether you think that someone needs escaping or not is irrelevant. - the regex is valid with escaping or without - this Chrome regression is causing real world (such as https://redmine.pfsense.org/issues/6762) - and no, it does NOT fail in Firefox) issues and is a valid bug - this is not limited to the @ character, see the pfSense issue linked above Kindly reopen and fix.
,
Sep 22 2016
tkent@ any opinions this falls into the forms domain.
,
Sep 22 2016
http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.5 Please, implement specs instead of personal preferences. There's nothing forbidding "overescaping" anywhere.
,
Sep 22 2016
I believe the spec implemented is https://tc39.github.io/ecma262/#sec-patterns
,
Sep 22 2016
The behavior difference in Comment #4 is a bug. We should fix. #5 and #7. This strict syntax checking is defined by standards. We need to specify Unicode flag to regular expression engine. https://html.spec.whatwg.org/multipage/forms.html#attr-input-pattern > when compiled as a JavaScript regular expression with only the "u" flag specified, compiles successfully,
,
Sep 23 2016
,
Sep 23 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/e7357db8054bca102ee953509b8264cdcd4f2e07 commit e7357db8054bca102ee953509b8264cdcd4f2e07 Author: tkent <tkent@chromium.org> Date: Fri Sep 23 11:41:02 2016 Fix pattern attribute handling for invalid regular expressions. If BaseTextInputType::patternMismatch() was called twice, the second call skipped ScriptRegexp::isValid() check. BUG= 639324 Review-Url: https://codereview.chromium.org/2366803002 Cr-Commit-Position: refs/heads/master@{#420604} [modify] https://crrev.com/e7357db8054bca102ee953509b8264cdcd4f2e07/third_party/WebKit/LayoutTests/fast/forms/ValidityState-patternMismatch-expected.txt [modify] https://crrev.com/e7357db8054bca102ee953509b8264cdcd4f2e07/third_party/WebKit/LayoutTests/fast/forms/ValidityState-patternMismatch.html [modify] https://crrev.com/e7357db8054bca102ee953509b8264cdcd4f2e07/third_party/WebKit/Source/core/html/forms/BaseTextInputType.cpp
,
Sep 25 2016
,
Sep 25 2016
Your change meets the bar and is auto-approved for M54 (branch: 2840)
,
Sep 26 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/698789f055c015f6b2b9cc7e3ba92ffffc50eee2 commit 698789f055c015f6b2b9cc7e3ba92ffffc50eee2 Author: Kent Tamura <tkent@chromium.org> Date: Mon Sep 26 00:23:14 2016 Merge "Fix pattern attribute handling for invalid regular expressions." to M54 branch If BaseTextInputType::patternMismatch() was called twice, the second call skipped ScriptRegexp::isValid() check. BUG= 639324 Review-Url: https://codereview.chromium.org/2366803002 Cr-Commit-Position: refs/heads/master@{#420604} (cherry picked from commit e7357db8054bca102ee953509b8264cdcd4f2e07) Review URL: https://codereview.chromium.org/2363323002 . Cr-Commit-Position: refs/branch-heads/2840@{#521} Cr-Branched-From: 1ae106dbab4bddd85132d5b75c670794311f4c57-refs/heads/master@{#414607} [modify] https://crrev.com/698789f055c015f6b2b9cc7e3ba92ffffc50eee2/third_party/WebKit/LayoutTests/fast/forms/ValidityState-patternMismatch-expected.txt [modify] https://crrev.com/698789f055c015f6b2b9cc7e3ba92ffffc50eee2/third_party/WebKit/LayoutTests/fast/forms/ValidityState-patternMismatch.html [modify] https://crrev.com/698789f055c015f6b2b9cc7e3ba92ffffc50eee2/third_party/WebKit/Source/core/html/forms/BaseTextInputType.cpp
,
Sep 28 2016
Verified the issue on Win 10 using beta # 54.0.2840.41 and the html file from Comment # 4.Its working fine now.Attached the screen cast for the same.
,
Oct 12 2016
Issue 655142 has been merged into this issue.
,
Oct 27 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/698789f055c015f6b2b9cc7e3ba92ffffc50eee2 commit 698789f055c015f6b2b9cc7e3ba92ffffc50eee2 Author: Kent Tamura <tkent@chromium.org> Date: Mon Sep 26 00:23:14 2016 Merge "Fix pattern attribute handling for invalid regular expressions." to M54 branch If BaseTextInputType::patternMismatch() was called twice, the second call skipped ScriptRegexp::isValid() check. BUG= 639324 Review-Url: https://codereview.chromium.org/2366803002 Cr-Commit-Position: refs/heads/master@{#420604} (cherry picked from commit e7357db8054bca102ee953509b8264cdcd4f2e07) Review URL: https://codereview.chromium.org/2363323002 . Cr-Commit-Position: refs/branch-heads/2840@{#521} Cr-Branched-From: 1ae106dbab4bddd85132d5b75c670794311f4c57-refs/heads/master@{#414607} [modify] https://crrev.com/698789f055c015f6b2b9cc7e3ba92ffffc50eee2/third_party/WebKit/LayoutTests/fast/forms/ValidityState-patternMismatch-expected.txt [modify] https://crrev.com/698789f055c015f6b2b9cc7e3ba92ffffc50eee2/third_party/WebKit/LayoutTests/fast/forms/ValidityState-patternMismatch.html [modify] https://crrev.com/698789f055c015f6b2b9cc7e3ba92ffffc50eee2/third_party/WebKit/Source/core/html/forms/BaseTextInputType.cpp |
|||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||
Comment 1 by dtapu...@chromium.org
, Aug 19 2016Labels: Needs-Feedback
It fails in FireFox as well.. I don't think you need the \@ escape... pattern="^([a-zA-Z0-9_\.\-\+])+@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$" should work correctly.