Bug 209273

Summary: StringView::startsWith and String::startsWith do not treat null strings the same
Product: WebKit Reporter: youenn fablet <youennf>
Component: WebKit Misc.Assignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cdumez, cmarcelo, darin, ews-watchlist, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description youenn fablet 2020-03-19 00:53:03 PDT
String::startsWith(null) returns false.
StringView::startsWith(null) returns true.
Both startsWith(emptyString) returns true.
Comment 1 youenn fablet 2020-03-19 07:13:42 PDT
Created attachment 393975 [details]
Patch
Comment 2 Darin Adler 2020-03-22 14:28:35 PDT
Comment on attachment 393975 [details]
Patch

I’m amazed. No one depended on the old behavior!?
Comment 3 youenn fablet 2020-03-23 02:28:05 PDT
(In reply to Darin Adler from comment #2)
> Comment on attachment 393975 [details]
> Patch
> 
> I’m amazed. No one depended on the old behavior!?

I was surprised too.
Looking at our code base though, most of startsWith use null terminated strings as prefix so will not end up in that particular case.
Comment 4 EWS 2020-03-23 02:48:17 PDT
Committed r258828: <https://trac.webkit.org/changeset/258828>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 393975 [details].
Comment 5 Radar WebKit Bug Importer 2020-03-23 02:49:14 PDT
<rdar://problem/60764657>