New issue
Advanced search Search tips

Issue 639324 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Sep 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug-Regression



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/
 
Cc: dtapu...@chromium.org
Labels: 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.

Comment 2 by d...@ssl247.co.uk, 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 .
Status: WontFix (was: Unconfirmed)
It failed in FireFox 48 for me.
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. 
@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.
Cc: tkent@chromium.org
Components: -Blink Blink>Forms
tkent@ any opinions this falls into the forms domain.
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.
I believe the spec implemented is https://tc39.github.io/ecma262/#sec-patterns

Comment 9 by tkent@chromium.org, Sep 22 2016

Components: -Blink>Forms Blink>Forms>Text
Labels: -Needs-Feedback
Status: Available (was: WontFix)
Summary: Invalid pattern attribute prevents form submission (was: HTML5 Pattern - regex not working)
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, 

Comment 10 by tkent@chromium.org, Sep 23 2016

Owner: tkent@chromium.org
Status: Started (was: Available)

Comment 12 by tkent@chromium.org, Sep 25 2016

Labels: -Type-Bug Merge-Request-54 M-54 Type-Bug-Regression
Status: Fixed (was: Started)

Comment 13 by dimu@chromium.org, Sep 25 2016

Labels: -Merge-Request-54 Merge-Approved-54 Hotlist-Merge-Approved
Your change meets the bar and is auto-approved for M54 (branch: 2840)
Project Member

Comment 14 by bugdroid1@chromium.org, Sep 26 2016

Labels: -merge-approved-54 merge-merged-2840
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

Labels: TE-Verified-54.0.2840.41 TE-Verified-M54
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.
639324_Sept_28.mp4
333 KB View Download
 Issue 655142  has been merged into this issue.
Project Member

Comment 17 by bugdroid1@chromium.org, 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