Changeset 255975 in webkit


Ignore:
Timestamp:
Feb 6, 2020 1:36:48 PM (4 years ago)
Author:
Alexey Shvayka
Message:

JavaScript string corruption using RegExp with unicode character
https://bugs.webkit.org/show_bug.cgi?id=187947

Reviewed by Yusuke Suzuki.

JSTests:

This change adds regression test for string corruption that occured after
non-BMP character was removed by String.prototype.replace.
The issue was fixed in https://trac.webkit.org/changeset/253648/webkit.

Also, this patch brings back:

  1. An out-of-order character class range test.
  2. Dangling and combined surrogates tests (as webkit.org/b/154863 is now resolved).
  • stress/regress-187947.js: Added.

LayoutTests:

Besides adding a regression test, this patch brings back:

  1. An out-of-order character class range test.
  2. Dangling and combined surrogates tests (as webkit.org/b/154863 is now resolved).
  • js/dom/regexp-range-out-of-order-expected.txt:
  • js/dom/script-tests/regexp-range-out-of-order.js:
  • js/regexp-unicode-expected.txt:
  • js/script-tests/regexp-extended-characters-match.js:
  • js/script-tests/regexp-unicode.js:
Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r255897 r255975  
     12020-02-06  Sukolsak Sakshuwong  <sukolsak@gmail.com> and Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        JavaScript string corruption using RegExp with unicode character
     4        https://bugs.webkit.org/show_bug.cgi?id=187947
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        This change adds regression test for string corruption that occured after
     9        non-BMP character was removed by String.prototype.replace.
     10        The issue was fixed in https://trac.webkit.org/changeset/253648/webkit.
     11
     12        Also, this patch brings back:
     13        1. An out-of-order character class range test.
     14        2. Dangling and combined surrogates tests (as webkit.org/b/154863 is now resolved).
     15
     16        * stress/regress-187947.js: Added.
     17
    1182020-02-05  Justin Michaud  <justin_michaud@apple.com>
    219
  • trunk/LayoutTests/ChangeLog

    r255973 r255975  
     12020-02-06  Sukolsak Sakshuwong  <sukolsak@gmail.com> and Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        JavaScript string corruption using RegExp with unicode character
     4        https://bugs.webkit.org/show_bug.cgi?id=187947
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        Besides adding a regression test, this patch brings back:
     9        1. An out-of-order character class range test.
     10        2. Dangling and combined surrogates tests (as webkit.org/b/154863 is now resolved).
     11
     12        * js/dom/regexp-range-out-of-order-expected.txt:
     13        * js/dom/script-tests/regexp-range-out-of-order.js:
     14        * js/regexp-unicode-expected.txt:
     15        * js/script-tests/regexp-extended-characters-match.js:
     16        * js/script-tests/regexp-unicode.js:
     17
    1182020-02-06  Commit Queue  <commit-queue@webkit.org>
    219
  • trunk/LayoutTests/js/dom/regexp-range-out-of-order-expected.txt

    r156066 r255975  
    55
    66PASS /^[s{-.[]()]$/ threw exception SyntaxError: Invalid regular expression: range out of order in character class.
     7PASS new RegExp("[ā-Ā]") threw exception SyntaxError: Invalid regular expression: range out of order in character class.
    78PASS successfullyParsed is true
    89
  • trunk/LayoutTests/js/dom/script-tests/regexp-range-out-of-order.js

    r156066 r255975  
    55);
    66
    7 shouldThrow('/^[\s{-.\[\]\(\)]$/');
     7shouldThrow('/^[\s{-.\[\]\(\)]$/', '"SyntaxError: Invalid regular expression: range out of order in character class"');
     8shouldThrow('new RegExp("[\u0101-\u0100]")', '"SyntaxError: Invalid regular expression: range out of order in character class"');
  • trunk/LayoutTests/js/regexp-unicode-expected.txt

    r255544 r255975  
    8787PASS re2.test("￿") is false
    8888PASS re2.test("𒍅") is true
     89PASS /[𐰁�#�]/u.exec("𐰁").toString() is "𐰁"
     90PASS /[�𐰁�]/u.exec("𐰁").toString() is "𐰁"
     91PASS /[�#�𐰁]/u.exec("𐰁").toString() is "𐰁"
     92PASS /[�𐰁�]/u.exec("𐰁").toString() is "𐰁"
     93PASS /[𐰁�#�]{2}/u.exec("𐰁") is null
     94PASS /[�𐰁�]{2}/u.exec("𐰁") is null
     95PASS /[�#�𐰁]{2}/u.exec("𐰁") is null
     96PASS /[�𐰁�]{2}/u.exec("𐰁") is null
     97PASS /�|�|𐰁/u.exec("𐰁").toString() is "𐰁"
     98PASS /�|𐰁|�/u.exec("𐰁").toString() is "𐰁"
     99PASS /�|�|𐰁/u.exec("�").toString() is "�"
     100PASS /�|𐰁|�/u.exec("�").toString() is "�"
     101PASS /�𐰁/u.exec("𐰁") is null
     102PASS /�𐰁/u.exec("�") is null
     103PASS "�𐰁".match(/�𐰁/u)[0].length is 3
    89104PASS /𝌆{2}/u.test("𝌆𝌆") is true
    90105PASS /𝌆{2}/u.test("𝌆𝌆") is true
  • trunk/LayoutTests/js/script-tests/regexp-extended-characters-match.js

    r98407 r255975  
    22"This test checks regular expressions using extended (> 255) characters and character classes."
    33);
    4 
    5 // shouldThrow('var r = new RegExp("[\u0101-\u0100]"); r.exec("a")', 'null');
    64
    75shouldBe('(new RegExp("[\u0100-\u0101]")).exec("a")', 'null');
  • trunk/LayoutTests/js/script-tests/regexp-unicode.js

    r255544 r255975  
    105105
    106106// Make sure we properly handle dangling surrogates and combined surrogates
    107 // FIXME: These tests are disabled until https://bugs.webkit.org/show_bug.cgi?id=154863 is fixed
    108 // shouldBe('/[\u{10c01}\uD803#\uDC01]/u.exec("\u{10c01}").toString()', '"\u{10c01}"');
    109 // shouldBe('/[\uD803\u{10c01}\uDC01]/u.exec("\u{10c01}").toString()', '"\u{10c01}"');
    110 // shouldBe('/[\uD803#\uDC01\u{10c01}]/u.exec("\u{10c01}").toString()', '"\u{10c01}"');
    111 // shouldBe('/[\uD803\uD803\uDC01\uDC01]/u.exec("\u{10c01}").toString()', '"\u{10c01}"');
    112 // shouldBeNull('/[\u{10c01}\uD803#\uDC01]{2}/u.exec("\u{10c01}")');
    113 // shouldBeNull('/[\uD803\u{10c01}\uDC01]{2}/u.exec("\u{10c01}")');
    114 // shouldBeNull('/[\uD803#\uDC01\u{10c01}]{2}/u.exec("\u{10c01}")');
    115 // shouldBeNull('/[\uD803\uD803\uDC01\uDC01]{2}/u.exec("\u{10c01}")');
    116 // shouldBe('/\uD803|\uDC01|\u{10c01}/u.exec("\u{10c01}").toString()', '"\u{10c01}"');
    117 // shouldBe('/\uD803|\uD803\uDC01|\uDC01/u.exec("\u{10c01}").toString()', '"\u{10c01}"');
    118 // shouldBe('/\uD803|\uDC01|\u{10c01}/u.exec("\u{D803}").toString()', '"\u{D803}"');
    119 // shouldBe('/\uD803|\uD803\uDC01|\uDC01/u.exec("\u{DC01}").toString()', '"\u{DC01}"');
    120 // shouldBeNull('/\uD803\u{10c01}/u.exec("\u{10c01}")');
    121 // shouldBeNull('/\uD803\u{10c01}/u.exec("\uD803")');
    122 // shouldBe('"\uD803\u{10c01}".match(/\uD803\u{10c01}/u)[0].length', '3');
     107shouldBe('/[\u{10c01}\uD803#\uDC01]/u.exec("\u{10c01}").toString()', '"\u{10c01}"');
     108shouldBe('/[\uD803\u{10c01}\uDC01]/u.exec("\u{10c01}").toString()', '"\u{10c01}"');
     109shouldBe('/[\uD803#\uDC01\u{10c01}]/u.exec("\u{10c01}").toString()', '"\u{10c01}"');
     110shouldBe('/[\uD803\uD803\uDC01\uDC01]/u.exec("\u{10c01}").toString()', '"\u{10c01}"');
     111shouldBeNull('/[\u{10c01}\uD803#\uDC01]{2}/u.exec("\u{10c01}")');
     112shouldBeNull('/[\uD803\u{10c01}\uDC01]{2}/u.exec("\u{10c01}")');
     113shouldBeNull('/[\uD803#\uDC01\u{10c01}]{2}/u.exec("\u{10c01}")');
     114shouldBeNull('/[\uD803\uD803\uDC01\uDC01]{2}/u.exec("\u{10c01}")');
     115shouldBe('/\uD803|\uDC01|\u{10c01}/u.exec("\u{10c01}").toString()', '"\u{10c01}"');
     116shouldBe('/\uD803|\uD803\uDC01|\uDC01/u.exec("\u{10c01}").toString()', '"\u{10c01}"');
     117shouldBe('/\uD803|\uDC01|\u{10c01}/u.exec("\u{D803}").toString()', '"\u{D803}"');
     118shouldBe('/\uD803|\uD803\uDC01|\uDC01/u.exec("\u{DC01}").toString()', '"\u{DC01}"');
     119shouldBeNull('/\uD803\u{10c01}/u.exec("\u{10c01}")');
     120shouldBeNull('/\uD803\u{10c01}/u.exec("\uD803")');
     121shouldBe('"\uD803\u{10c01}".match(/\uD803\u{10c01}/u)[0].length', '3');
    123122
    124123// Check quantified matches
Note: See TracChangeset for help on using the changeset viewer.