[webkit-changes] [WebKit/WebKit] ebf196: String.prototype.includes incorrectly returns fals...
Darin Adler
noreply at github.com
Fri Sep 9 12:47:08 PDT 2022
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: ebf196ed572433cb92280dac2a1d62a57ce773b5
https://github.com/WebKit/WebKit/commit/ebf196ed572433cb92280dac2a1d62a57ce773b5
Author: Darin Adler <darin at apple.com>
Date: 2022-09-09 (Fri, 09 Sep 2022)
Changed paths:
M LayoutTests/js/script-tests/string-includes.js
M LayoutTests/js/string-includes-expected.txt
M Source/JavaScriptCore/runtime/StringPrototype.cpp
Log Message:
-----------
String.prototype.includes incorrectly returns false when string is empty and position is past end of string
https://bugs.webkit.org/show_bug.cgi?id=244196
Reviewed by Alexey Shvayka.
Added length clamping to the Int32 special case of the startsWith
and includes functions. These functions could be optimized for all sorts
of cases including not fetching string lengths multiple times, and even
optimizing rope cases to not require resolving the whole rope, but for now
didn't worry about any of that, just added that bit of extra checking.
* LayoutTests/js/script-tests/string-includes.js: Added test cases.
* LayoutTests/js/string-includes-expected.txt: Added expected result.
* Source/JavaScriptCore/runtime/StringPrototype.cpp:
(JSC::stringProtoFuncStartsWith): Added clamping to the Int32 special case.
(JSC::stringProtoFuncEndsWith): Refactored clamping to match startsWith
and includes, which removes one redudant clamp.
(JSC::stringIncludesImpl): Added clamping to the Int32 special case.
Canonical link: https://commits.webkit.org/254319@main
More information about the webkit-changes
mailing list