Ignore:
Timestamp:
Mar 22, 2021, 3:06:52 PM (4 years ago)
Author:
[email protected]
Message:

[YARR] Interpreter incorrectly matches non-BMP characters with multiple .
https://bugs.webkit.org/show_bug.cgi?id=223498

Reviewed by Yusuke Suzuki.

JSTests:

New test.

  • stress/regexp-dot-match-nonBMP.js: Added.

(shouldMatch):
(shouldntMatch):

Source/JavaScriptCore:

We need to check that we read an actual character before seeing if it is part of a character class.
In the case where we are checking that a character is not in a character class, like .,
the failed to read result from input.readChecked(), -1, is not part of the newline character class.
This will allow regular expressions that require more than the number of characters in a string
to match.

  • yarr/YarrInterpreter.cpp:

(JSC::Yarr::Interpreter::checkCharacterClass):

LayoutTests:

Updated test.

  • fast/forms/ValidityState-patternMismatch-expected.txt:
  • fast/forms/ValidityState-patternMismatch.html:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/yarr/YarrInterpreter.cpp

    r261755 r274806  
    426426    bool checkCharacterClass(CharacterClass* characterClass, bool invert, unsigned negativeInputOffset)
    427427    {
    428         bool match = testCharacterClass(characterClass, input.readChecked(negativeInputOffset));
     428        int inputChar = input.readChecked(negativeInputOffset);
     429        if (inputChar < 0)
     430            return false;
     431
     432        bool match = testCharacterClass(characterClass, inputChar);
    429433        return invert ? !match : match;
    430434    }
Note: See TracChangeset for help on using the changeset viewer.