Closed Bug 1783830 Opened 2 years ago Closed 2 years ago

Negated character classes of RegExp with 'u' flag do not match correctly

Categories

(Core :: JavaScript Engine, defect, P2)

Firefox 103
defect

Tracking

()

RESOLVED FIXED
106 Branch
Tracking Status
firefox106 --- fixed

People

(Reporter: danny0838, Assigned: iain)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0

Steps to reproduce:

/[^!]/u.exec('\u{1F4A9}');  // ["\u{1F4A9}"]
/^[^!]/u.exec('\u{1F4A9}');  // ["\u{1F4A9}"]
/[^!]$/u.exec('\u{1F4A9}');  // ["\u{1F4A9}"]
/![^!]/u.exec('!\u{1F4A9}');  // ["!\uD83D"] (expect ["!\u{1F4A9}"])
/[^!]!/u.exec('\u{1F4A9}!');  // ["\uDCA9!"] (expect ["\u{1F4A9}!"])
/![^!]/ui.exec('!\u{1F4A9}');  // ["\u{1F4A9}"]
/[^!]!/ui.exec('\u{1F4A9}!');  // ["\u{1F4A9}"]

Actual results:

When the 'u' flag is set for an RegExp, a negated character class sometimes does not match a whole surrogate pair.

Expected results:

When the 'u' flag is set for an RegExp, a negated character class should match a whole surrogate pair.

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

Component: Untriaged → JavaScript Engine
Product: Firefox → Core

I believe this is our equivalent of this bug in upstream irregexp. I will be refreshing our import of irregexp to fix bug 1783555; I will double-check that the upstream fix also fixes this bug.

Severity: -- → S3
Priority: -- → P2
Attached file Bug 1783830: Add testcase r=sfink (deleted) —

Depends on D155915

Assignee: nobody → iireland
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 106 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: