Closed Bug 1848118 Opened 1 year ago Closed 1 year ago

Incorrect pattern attribute parsing

Categories

(Core :: DOM: Core & HTML, defect)

Firefox 116
defect

Tracking

()

RESOLVED INVALID
Tracking Status
thunderbird_esr115 --- unaffected
firefox-esr102 --- unaffected
firefox-esr115 --- unaffected
firefox116 --- wontfix
firefox117 --- wontfix
firefox118 --- wontfix

People

(Reporter: jarvisa62, Unassigned)

References

(Regression)

Details

(Keywords: regression, regressionwindow-wanted)

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0

Steps to reproduce:

Open the attached file in the FireFox.
Press F12 to launch the developer tools.
Go to the ‘Console’ tab.

Actual results:

The script invokes RegExp.test on some sample strings using the pattern in the <input> element.
These tests produce the expected results, however the console window is showing the error:
Unable to check <input pattern='^[+-]?\d+$'> because the pattern is not a valid regexp: invalid character in class in regular expression

Expected results:

The pattern attribute does not accept the ‘-’ that is not part of a range expression, although this is allowed by the specification.
https://tc39.es/ecma262/multipage/text-processing.html#sec-regexp-regular-expression-objects

‘NonemptyClassRanges’ can be ‘ClassAtom NonemptyClassRangesNoDash’
‘NonemptyClassRangesNoDash’ can be ‘ClassAtom’
‘ClassAtom’ can be ‘-’

This was broken fairly recently. I noticed validation problems maybe a few weeks ago but only investigated today.

Why is the pattern attribute using a different parser to the RegExp object?

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Core & HTML' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core

regexp showing expected output, but console showing error - > Reclassify to DEvTools: Console.

Component: DOM: Core & HTML → Console
Product: Core → DevTools

This is not a DevTools issue, the console is only showing the error message sent by the platform.
I can reproduce on release, and the error message wasn't there on ESR 102

Status: UNCONFIRMED → NEW
Component: Console → DOM: Core & HTML
Ever confirmed: true
Product: DevTools → Core

Set release status flags based on info from the regressing bug 1814870

:peterv, since you are the author of the regressor, bug 1814870, could you take a look? Also, could you set the severity field?

For more information, please visit BugBot documentation.

Flags: needinfo?(peterv)

(In reply to Andrew Jarvis from comment #0)

Why is the pattern attribute using a different parser to the RegExp object?

The pattern attribute uses RegExpCreate(pattern, "v") (see step 3 in https://html.spec.whatwg.org/#the-pattern-attribute). You'll need to pass v to the RegExp constructor if you want to use it with a pattern attribute's value, and the pattern attribute's value needs to use v-mode character classes (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class#v-mode_character_class).

Status: NEW → RESOLVED
Closed: 1 year ago
Flags: needinfo?(peterv)
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: