Title: [258828] trunk
- Revision
- 258828
- Author
- you...@apple.com
- Date
- 2020-03-23 02:48:12 -0700 (Mon, 23 Mar 2020)
Log Message
StringView::startsWith and String::startsWith do not treat null strings the same
https://bugs.webkit.org/show_bug.cgi?id=209273
Reviewed by Darin Adler.
Source/WTF:
Align StringImpl with StringView and make startsWith return true if prefix is null.
* wtf/text/StringImpl.cpp:
(WTF::StringImpl::startsWith const):
Tools:
* TestWebKitAPI/Tests/WTF/StringView.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WTF/WTFString.cpp:
(TestWebKitAPI::TEST):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (258827 => 258828)
--- trunk/Source/WTF/ChangeLog 2020-03-23 09:05:26 UTC (rev 258827)
+++ trunk/Source/WTF/ChangeLog 2020-03-23 09:48:12 UTC (rev 258828)
@@ -1,3 +1,15 @@
+2020-03-23 youenn fablet <you...@apple.com>
+
+ StringView::startsWith and String::startsWith do not treat null strings the same
+ https://bugs.webkit.org/show_bug.cgi?id=209273
+
+ Reviewed by Darin Adler.
+
+ Align StringImpl with StringView and make startsWith return true if prefix is null.
+
+ * wtf/text/StringImpl.cpp:
+ (WTF::StringImpl::startsWith const):
+
2020-03-22 Antoine Quint <grao...@apple.com>
DocumentTimeline / CSSTransition objects are leaking on CNN.com
Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (258827 => 258828)
--- trunk/Source/WTF/wtf/text/StringImpl.cpp 2020-03-23 09:05:26 UTC (rev 258827)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp 2020-03-23 09:48:12 UTC (rev 258828)
@@ -1183,7 +1183,7 @@
bool StringImpl::startsWith(const StringImpl* string) const
{
- return string && ::WTF::startsWith(*this, *string);
+ return !string || ::WTF::startsWith(*this, *string);
}
bool StringImpl::startsWith(const StringImpl& string) const
Modified: trunk/Tools/ChangeLog (258827 => 258828)
--- trunk/Tools/ChangeLog 2020-03-23 09:05:26 UTC (rev 258827)
+++ trunk/Tools/ChangeLog 2020-03-23 09:48:12 UTC (rev 258828)
@@ -1,3 +1,15 @@
+2020-03-23 youenn fablet <you...@apple.com>
+
+ StringView::startsWith and String::startsWith do not treat null strings the same
+ https://bugs.webkit.org/show_bug.cgi?id=209273
+
+ Reviewed by Darin Adler.
+
+ * TestWebKitAPI/Tests/WTF/StringView.cpp:
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WTF/WTFString.cpp:
+ (TestWebKitAPI::TEST):
+
2020-03-22 Antoine Quint <grao...@apple.com>
DocumentTimeline / CSSTransition objects are leaking on CNN.com
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp (258827 => 258828)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp 2020-03-23 09:05:26 UTC (rev 258827)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp 2020-03-23 09:48:12 UTC (rev 258828)
@@ -41,6 +41,17 @@
return ref;
}
+TEST(WTF, StringViewStartsWithEmptyVsNull)
+{
+ StringView nullView;
+ StringView emptyView = StringView::empty();
+ String stringWithCharacters("hello");
+ StringView viewWithCharacters(stringWithCharacters);
+
+ EXPECT_TRUE(viewWithCharacters.startsWith(nullView));
+ EXPECT_TRUE(viewWithCharacters.startsWith(emptyView));
+}
+
TEST(WTF, StringViewEmptyVsNull)
{
StringView nullView;
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp (258827 => 258828)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp 2020-03-23 09:05:26 UTC (rev 258827)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp 2020-03-23 09:48:12 UTC (rev 258828)
@@ -71,6 +71,16 @@
EXPECT_STREQ("foobar", output.data());
}
+TEST(WTF, StringStartsWithEmptyVsNull)
+{
+ String nullString;
+ String emptyString = WTF::emptyString();
+ String stringWithCharacters("hello");
+
+ EXPECT_TRUE(stringWithCharacters.startsWith(nullString));
+ EXPECT_TRUE(stringWithCharacters.startsWith(emptyString));
+}
+
static inline const char* testStringNumberFixedPrecision(double number)
{
static char testBuffer[100] = { };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes