Bug 206768

Summary: Invalid ranges in character classes should be syntax errors in Unicode patterns only
Product: WebKit Reporter: Alexey Shvayka <ashvayka>
Component: JavaScriptCoreAssignee: Alexey Shvayka <ashvayka>
Status: RESOLVED FIXED    
Severity: Trivial CC: commit-queue, darin, ews-watchlist, keith_miller, mark.lam, msaboff, saam, tzagallo, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch none

Description Alexey Shvayka 2020-01-24 13:41:24 PST
In ES5, grammar of CharacterRange was ambiguous, resulting in invalid ranges like /[\d-a]/ being allowed.
As of ES2015, invalid ranges are SyntaxError in unicode patterns, yet still allowed in regular ones to avoid breaking the web.

Test case:
  /[a-\d]/u

Expected:
  SyntaxError thrown

Actual:
  RegExp instance

ECMA262: https://tc39.es/ecma262/#sec-patterns-static-semantics-early-errors-annexb
Test262:
  https://test262.report/browse/built-ins/RegExp/unicode_restricted_character_class_escape.js
  test/built-ins/RegExp/property-escapes/character-class-range*.js
  test/language/literals/regexp/u-invalid-non-empty-class-ranges*.js
Comment 1 Alexey Shvayka 2020-01-24 13:58:46 PST
Created attachment 388721 [details]
Patch
Comment 2 Darin Adler 2020-01-26 14:23:23 PST
Comment on attachment 388721 [details]
Patch

Seems like we keep saying “unicode” in error messages but it should be “Unicode”. It’s a propert noun not a common one.
Comment 3 WebKit Commit Bot 2020-01-26 15:28:18 PST
The commit-queue encountered the following flaky tests while processing attachment 388721 [details]:

editing/spelling/spellcheck-attribute.html bug 206178 (authors: g.czajkowski@samsung.com, mark.lam@apple.com, and rniwa@webkit.org)
The commit-queue is continuing to process your patch.
Comment 4 WebKit Commit Bot 2020-01-26 15:28:49 PST
Comment on attachment 388721 [details]
Patch

Clearing flags on attachment: 388721

Committed r255134: <https://trac.webkit.org/changeset/255134>
Comment 5 WebKit Commit Bot 2020-01-26 15:28:50 PST
All reviewed patches have been landed.  Closing bug.
Comment 6 Radar WebKit Bug Importer 2020-01-26 15:29:12 PST
<rdar://problem/58905705>