Closed Bug 1862199 Opened 1 year ago Closed 5 months ago

Indicate regex flag used for pattern attribute in invalid pattern error message

Categories

(Core :: DOM: Forms, defect)

defect

Tracking

()

VERIFIED FIXED
129 Branch
Tracking Status
firefox129 --- verified
firefox130 --- verified

People

(Reporter: nchevobbe, Assigned: vhilla)

Details

Attachments

(1 file)

Steps to reproduce

  1. Go to data:text/html,<meta charset=utf8><input pattern="[a-]">
  2. Open the webconsole
  3. Type a character in the page input
  4. See the error message displayed in the console

Actual results

The message is the following:

Unable to check <input pattern='[a-]'> because the pattern is not a valid regexp: invalid character in class in regular expression

It's quite hard to understand what is going on at this point, as /[a-]/ is a valid Regexp

Expected results

We should indicate that the regex is not valid with the v flag, which might indicate to the developer where the issue might come from.

Chrome console message is:

Uncaught SyntaxError: Invalid regular expression: /[a-]/v: Invalid character in character class

they even had an earlier one that was saying that the regex was valid with the u flag but not with the v flag, which was even more helpful, as you could look the differences between the two.

Severity: -- → S3

The same on e-mail pattern:

<input id="xy" maxlength="100" name="KeyAccOrderer" pattern="[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,14}$" type="email" value="andrejlnnk@web.de">

any input log: invalid character in class in regular expression

Assignee: nobody → vhilla
Status: NEW → ASSIGNED
Pushed by vhilla@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2a4ee9f86e5a Report invalid pattern attribute together with the regex flag. r=dom-core,peterv,iain

Backed out for causing bc failures on browser_misused_characters_in_strings.js.

[task 2024-06-04T08:51:07.732Z] 08:51:07     INFO - TEST-START | browser/base/content/test/static/browser_misused_characters_in_strings.js
[task 2024-06-04T08:51:07.777Z] 08:51:07     INFO - TEST-INFO | started process screentopng
[task 2024-06-04T08:51:07.962Z] 08:51:07     INFO - TEST-INFO | screentopng: exit 0
[task 2024-06-04T08:51:07.964Z] 08:51:07     INFO - Buffered messages logged at 08:51:07
[task 2024-06-04T08:51:07.965Z] 08:51:07     INFO - Entering test bound checkAllTheProperties
[task 2024-06-04T08:51:07.967Z] 08:51:07     INFO - TEST-PASS | browser/base/content/test/static/browser_misused_characters_in_strings.js | Found 113 .properties files to scan for misused characters - 
[task 2024-06-04T08:51:07.971Z] 08:51:07     INFO - Buffered messages finished
[task 2024-06-04T08:51:07.971Z] 08:51:07     INFO - TEST-UNEXPECTED-FAIL | browser/base/content/test/static/browser_misused_characters_in_strings.js | jar:file:///builds/worker/workspace/build/application/firefox/omni.ja!/chrome/en-US/locale/en-US/global/dom/dom.properties with key=PatternAttributeCompileFailurev2 has a misused single-quote. Single-quoted strings should use Unicode ‘foo’ instead of 'foo'. - 
[task 2024-06-04T08:51:07.971Z] 08:51:07     INFO - Stack trace:
[task 2024-06-04T08:51:07.971Z] 08:51:07     INFO - chrome://mochikit/content/browser-test.js:test_ok:1592
[task 2024-06-04T08:51:07.971Z] 08:51:07     INFO - chrome://mochitests/content/browser/browser/base/content/test/static/browser_misused_characters_in_strings.js:testForError:121
[task 2024-06-04T08:51:07.972Z] 08:51:07     INFO - chrome://mochitests/content/browser/browser/base/content/test/static/browser_misused_characters_in_strings.js:testForErrors:142
[task 2024-06-04T08:51:07.972Z] 08:51:07     INFO - chrome://mochitests/content/browser/browser/base/content/test/static/browser_misused_characters_in_strings.js:checkAllTheProperties:198
[task 2024-06-04T08:51:07.972Z] 08:51:07     INFO - chrome://mochikit/content/browser-test.js:handleTask:1139
[task 2024-06-04T08:51:07.972Z] 08:51:07     INFO - chrome://mochikit/content/browser-test.js:_runTaskBasedTest:1211
[task 2024-06-04T08:51:07.972Z] 08:51:07     INFO - chrome://mochikit/content/browser-test.js:Tester_execTest:1353
[task 2024-06-04T08:51:07.972Z] 08:51:07     INFO - chrome://mochikit/content/browser-test.js:nextTest/<:1128
[task 2024-06-04T08:51:07.972Z] 08:51:07     INFO - chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:SimpleTest.waitForFocus/<:1058
[task 2024-06-04T08:51:07.974Z] 08:51:07     INFO - Not taking screenshot here: see the one that was previously logged
[task 2024-06-04T08:51:07.976Z] 08:51:07     INFO - TEST-UNEXPECTED-FAIL | browser/base/content/test/static/browser_misused_characters_in_strings.js | jar:file:///builds/worker/workspace/build/application/firefox/omni.ja!/res/locale/dom/dom.properties with key=PatternAttributeCompileFailurev2 has a misused single-quote. Single-quoted strings should use Unicode ‘foo’ instead of 'foo'. - 
[task 2024-06-04T08:51:07.976Z] 08:51:07     INFO - Stack trace:
[task 2024-06-04T08:51:07.977Z] 08:51:07     INFO - chrome://mochikit/content/browser-test.js:test_ok:1592
[task 2024-06-04T08:51:07.977Z] 08:51:07     INFO - chrome://mochitests/content/browser/browser/base/content/test/static/browser_misused_characters_in_strings.js:testForError:121
[task 2024-06-04T08:51:07.977Z] 08:51:07     INFO - chrome://mochitests/content/browser/browser/base/content/test/static/browser_misused_characters_in_strings.js:testForErrors:142
[task 2024-06-04T08:51:07.977Z] 08:51:07     INFO - chrome://mochitests/content/browser/browser/base/content/test/static/browser_misused_characters_in_strings.js:checkAllTheProperties:198
[task 2024-06-04T08:51:07.977Z] 08:51:07     INFO - chrome://mochikit/content/browser-test.js:handleTask:1139
[task 2024-06-04T08:51:07.977Z] 08:51:07     INFO - chrome://mochikit/content/browser-test.js:_runTaskBasedTest:1211
[task 2024-06-04T08:51:07.977Z] 08:51:07     INFO - chrome://mochikit/content/browser-test.js:Tester_execTest:1353
[task 2024-06-04T08:51:07.977Z] 08:51:07     INFO - chrome://mochikit/content/browser-test.js:nextTest/<:1128
[task 2024-06-04T08:51:07.977Z] 08:51:07     INFO - chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:SimpleTest.waitForFocus/<:1058
[task 2024-06-04T08:51:07.977Z] 08:51:07     INFO - Leaving test bound checkAllTheProperties
[task 2024-06-04T08:51:07.978Z] 08:51:07     INFO - Entering test bound checkAllTheDTDs
[task 2024-06-04T08:51:07.978Z] 08:51:07     INFO - TEST-PASS | browser/base/content/test/static/browser_misused_characters_in_strings.js | Found 1 .dtd files to scan for misused characters - 
Flags: needinfo?(vhilla)

browser/base/content/test/static/browser_misused_characters_in_strings.js had an exception for PatternAttributeCompileFailure and when changing the string, I did not remember to fix the pre-existing issue.

Flags: needinfo?(vhilla)
Pushed by vhilla@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4a34f903f7cd Report invalid pattern attribute together with the regex flag. r=dom-core,peterv,iain
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 129 Branch

Reproducible on a 2024-06-09 Nightly build on Windows 10 using the steps from Comment 0.
Verified as fixed on Firefox Nightly 130.0a1 and Firefox 129.0b4 on Windows 10, Ubuntu 22, macOS 14.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: