Bug 206768 - Invalid ranges in character classes should be syntax errors in Unicode patterns only
Summary: Invalid ranges in character classes should be syntax errors in Unicode patter...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Trivial
Assignee: Alexey Shvayka
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-01-24 13:41 PST by Alexey Shvayka
Modified: 2020-01-26 15:29 PST (History)
10 users (show)

See Also:


Attachments
Patch (17.56 KB, patch)
2020-01-24 13:58 PST, Alexey Shvayka
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>