Skip to content

Commit daf65f7

Browse files
committed
Add find()/reverseFind()/contains() overloads takes an ASCIILiteral to our String types https://bugs.webkit.org/show_bug.cgi?id=240247
https://bugs.webkit.org/show_bug.cgi?id=240247 Reviewed by Darin Adler. Add find()/reverseFind()/contains() overloads takes an ASCIILiteral to our String types. These versions are more efficient when the call sites have an ASCIILiteral as they have less branching. * Source/JavaScriptCore/runtime/ExceptionHelpers.cpp: (JSC::notAFunctionSourceAppender): (JSC::invalidParameterInSourceAppender): (JSC::invalidParameterInstanceofSourceAppender): (JSC::invalidPrototypeSourceAppender): * Source/JavaScriptCore/runtime/IntlObject.cpp: (JSC::canonicalizeUnicodeExtensionsAfterICULocaleCanonicalization): (JSC::lookupMatcher): * Source/JavaScriptCore/tools/FunctionOverrides.cpp: (JSC::initializeOverrideInfo): * Source/WebCore/PAL/pal/text/DecodeEscapeSequences.h: (PAL::Unicode16BitEscapeSequence::findInString): * Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp: (WebKit::needsNewCreateTableSchema): (WebKit::ResourceLoadStatisticsDatabaseStore::insertDomainRelationshipList): * Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp: (WebKit::NetworkResourceLoader::didReceiveResponse): * Source/WebKit/NetworkProcess/cache/PrefetchCache.cpp: (WebKit::PrefetchCache::take): * Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _updateTextInputTraits:]): * Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::focusedElementInformation): * Source/WebKit/WebProcess/WebProcess.cpp: (WebKit::checkDocumentsCaptureStateConsistency): * Source/WebKitLegacy/mac/WebView/WebView.mm: (-[WebView updateTextTouchBar]): * Source/WTF/wtf/text/AtomString.h: * Source/WTF/wtf/text/StringImpl.cpp: (WTF::StringImpl::find): (WTF::StringImpl::reverseFind): * Source/WTF/wtf/text/StringImpl.h: (WTF::StringImpl::find): (WTF::StringImpl::reverseFind): * Source/WTF/wtf/text/StringView.cpp: (WTF::StringView::find const): (WTF::StringView::reverseFind const): * Source/WTF/wtf/text/StringView.h: * Source/WTF/wtf/text/WTFString.h: * Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp: (WebCore::FetchBodyConsumer::packageFormData): * Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp: (WebCore::PeerConnectionBackend::validateSDP const): (WebCore::PeerConnectionBackend::newICECandidate): * Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp: (WebCore::YouTubePluginReplacement::youTubeURLFromAbsoluteURL): * Source/WebCore/dom/DataTransfer.cpp: (WebCore::DataTransfer::types const): * Source/WebCore/dom/Document.cpp: (WebCore::Document::createCDATASection): (WebCore::Document::createProcessingInstruction): * Source/WebCore/editing/cocoa/HTMLConverter.mm: (HTMLConverter::computedAttributesForElement): * Source/WebCore/editing/libwpe/EditorLibWPE.cpp: (WebCore::createFragmentFromPasteboardData): * Source/WebCore/editing/markup.cpp: (WebCore::StyledMarkupAccumulator::shouldPreserveMSOListStyleForElement): (WebCore::StyledMarkupAccumulator::appendNodeToPreserveMSOList): (WebCore::shouldPreserveMSOLists): * Source/WebCore/html/track/VTTRegion.cpp: (WebCore::VTTRegion::parseSettingValue): * Source/WebCore/html/track/WebVTTParser.cpp: (WebCore::WebVTTParser::collectWebVTTBlock): (WebCore::WebVTTParser::checkAndRecoverCue): (WebCore::WebVTTParser::checkAndCreateRegion): (WebCore::WebVTTParser::checkAndStoreRegion): (WebCore::WebVTTParser::checkStyleSheet): (WebCore::WebVTTParser::checkAndStoreStyleSheet): (WebCore::WebVTTParser::collectCueId): (WebCore::WebVTTParser::collectCueText): (WebCore::WebVTTParser::ignoreBadCue): * Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp: (WebCore::GStreamerRegistryScanner::ElementFactories::hasElementForMediaType const): * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): * Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLCommon.cpp: (WebCore::ExtensionsGLOpenGLCommon::ExtensionsGLOpenGLCommon): * Source/WebCore/platform/graphics/texmap/TextureMapperContextAttributes.cpp: (WebCore::TextureMapperContextAttributes::get): * Source/WebCore/platform/ios/UserAgentIOS.mm: (WebCore::deviceNameForUserAgent): * Source/WebCore/platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp: (WebCore::isValidCaptureDevice): * Source/WebCore/rendering/style/GridPositionsResolver.cpp: (WebCore::NamedLineCollectionBase::NamedLineCollectionBase): * Source/WebCore/style/StyleScope.cpp: (WebCore::Style::Scope::collectActiveStyleSheets): * Source/WebCore/testing/Internals.cpp: (WebCore::Internals::isVP9VTBDeccoderUsed): * Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp: (WebCore::MockLibWebRTCPeerConnection::SetRemoteDescription): Canonical link: https://commits.webkit.org/250730@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294468 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 4c7524f commit daf65f7

40 files changed

+149
-109
lines changed

Source/JavaScriptCore/runtime/ExceptionHelpers.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static String notAFunctionSourceAppender(const String& originalMessage, StringVi
161161
return defaultApproximateSourceError(originalMessage, sourceText);
162162

163163
ASSERT(occurrence == ErrorInstance::FoundExactSource);
164-
auto notAFunctionIndex = originalMessage.reverseFind("is not a function");
164+
auto notAFunctionIndex = originalMessage.reverseFind("is not a function"_s);
165165
RELEASE_ASSERT(notAFunctionIndex != notFound);
166166
StringView displayValue;
167167
if (originalMessage.is8Bit())
@@ -197,14 +197,14 @@ static String invalidParameterInSourceAppender(const String& originalMessage, St
197197
return defaultApproximateSourceError(originalMessage, sourceText);
198198

199199
ASSERT(occurrence == ErrorInstance::FoundExactSource);
200-
auto inIndex = sourceText.reverseFind("in");
200+
auto inIndex = sourceText.reverseFind("in"_s);
201201
if (inIndex == notFound) {
202202
// This should basically never happen, since JS code must use the literal
203203
// text "in" for the `in` operation. However, if we fail to find "in"
204204
// for any reason, just fail gracefully.
205205
return originalMessage;
206206
}
207-
if (sourceText.find("in") != inIndex)
207+
if (sourceText.find("in"_s) != inIndex)
208208
return makeString(originalMessage, " (evaluating '", sourceText, "')");
209209

210210
static constexpr unsigned inLength = 2;
@@ -218,12 +218,12 @@ inline String invalidParameterInstanceofSourceAppender(const String& content, co
218218
return defaultApproximateSourceError(originalMessage, sourceText);
219219

220220
ASSERT(occurrence == ErrorInstance::FoundExactSource);
221-
auto instanceofIndex = sourceText.reverseFind("instanceof");
221+
auto instanceofIndex = sourceText.reverseFind("instanceof"_s);
222222
// This can happen when Symbol.hasInstance function is directly called.
223223
if (instanceofIndex == notFound)
224224
return originalMessage;
225225

226-
if (sourceText.find("instanceof") != instanceofIndex)
226+
if (sourceText.find("instanceof"_s) != instanceofIndex)
227227
return makeString(originalMessage, " (evaluating '", sourceText, "')");
228228

229229
static constexpr unsigned instanceofLength = 10;
@@ -246,8 +246,8 @@ static String invalidPrototypeSourceAppender(const String& originalMessage, Stri
246246
if (occurrence == ErrorInstance::FoundApproximateSource)
247247
return defaultApproximateSourceError(originalMessage, sourceText);
248248

249-
auto extendsIndex = sourceText.reverseFind("extends");
250-
if (extendsIndex == notFound || sourceText.find("extends") != extendsIndex)
249+
auto extendsIndex = sourceText.reverseFind("extends"_s);
250+
if (extendsIndex == notFound || sourceText.find("extends"_s) != extendsIndex)
251251
return makeString(originalMessage, " (evaluating '", sourceText, "')");
252252

253253
return "The value of the superclass's prototype property is not an object or null."_s;

Source/JavaScriptCore/runtime/IntlObject.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ Vector<char, 32> canonicalizeUnicodeExtensionsAfterICULocaleCanonicalization(Vec
320320
{
321321
StringView locale(buffer.data(), buffer.size());
322322
ASSERT(locale.is8Bit());
323-
size_t extensionIndex = locale.find("-u-");
323+
size_t extensionIndex = locale.find("-u-"_s);
324324
if (extensionIndex == notFound)
325325
return WTFMove(buffer);
326326

@@ -855,7 +855,7 @@ static MatcherResult lookupMatcher(JSGlobalObject* globalObject, const LocaleSet
855855
if (!availableLocale.isEmpty()) {
856856
result.locale = availableLocale;
857857
if (locale != noExtensionsLocale) {
858-
size_t extensionIndex = locale.find("-u-");
858+
size_t extensionIndex = locale.find("-u-"_s);
859859
RELEASE_ASSERT(extensionIndex != notFound);
860860

861861
size_t extensionLength = locale.length() - extensionIndex;

Source/JavaScriptCore/tools/FunctionOverrides.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static void initializeOverrideInfo(const SourceCode& origCode, const String& new
130130
FunctionOverridesAssertScope assertScope;
131131
String origProviderStr = origCode.provider()->source().toString();
132132
unsigned origStart = origCode.startOffset();
133-
unsigned origFunctionStart = origProviderStr.reverseFind("function", origStart);
133+
unsigned origFunctionStart = origProviderStr.reverseFind("function"_s, origStart);
134134
unsigned origBraceStart = origProviderStr.find('{', origStart);
135135
unsigned headerLength = origBraceStart - origFunctionStart;
136136
auto origHeaderView = StringView(origProviderStr).substring(origFunctionStart, headerLength);

Source/WTF/wtf/text/AtomString.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,17 @@ class AtomString final {
9797
// If we need more overloads of the number function, we can add all the others that String has, but these seem to do for now.
9898

9999
bool contains(UChar character) const { return m_string.contains(character); }
100-
bool contains(const LChar* string) const { return m_string.contains(string); }
100+
bool contains(ASCIILiteral literal) const { return m_string.contains(literal); }
101+
bool contains(const char*) const = delete;
101102
bool contains(StringView) const;
102103
bool containsIgnoringASCIICase(StringView) const;
103104

104105
size_t find(UChar character, unsigned start = 0) const { return m_string.find(character, start); }
105-
size_t find(const LChar* string, unsigned start = 0) const { return m_string.find(string, start); }
106+
size_t find(ASCIILiteral literal, unsigned start = 0) const { return m_string.find(literal, start); }
107+
size_t find(const char*, unsigned start = 0) const = delete;
106108
size_t find(StringView, unsigned start = 0) const;
107109
size_t findIgnoringASCIICase(StringView) const;
110+
size_t findIgnoringASCIICase(const char*) const = delete;
108111
size_t findIgnoringASCIICase(StringView, unsigned start) const;
109112
size_t find(CodeUnitMatchFunction matchFunction, unsigned start = 0) const { return m_string.find(matchFunction, start); }
110113

Source/WTF/wtf/text/StringImpl.cpp

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -809,24 +809,10 @@ float StringImpl::toFloat(bool* ok)
809809
return charactersToFloat(characters16(), m_length, ok);
810810
}
811811

812-
size_t StringImpl::find(const LChar* matchString, unsigned start)
812+
size_t StringImpl::find(const LChar* matchString, unsigned matchLength, unsigned start)
813813
{
814-
// Check for null or empty string to match against
815-
if (!matchString)
816-
return notFound;
817-
size_t matchStringLength = strlen(reinterpret_cast<const char*>(matchString));
818-
if (matchStringLength > MaxLength)
819-
CRASH();
820-
unsigned matchLength = matchStringLength;
821-
if (!matchLength)
822-
return std::min(start, length());
823-
824-
// Optimization 1: fast case for strings of length 1.
825-
if (matchLength == 1) {
826-
if (is8Bit())
827-
return WTF::find(characters8(), length(), matchString[0], start);
828-
return WTF::find(characters16(), length(), *matchString, start);
829-
}
814+
ASSERT(matchLength);
815+
ASSERT(matchLength <= MaxLength);
830816

831817
// Check start & matchLength are in range.
832818
if (start > length())
@@ -837,7 +823,7 @@ size_t StringImpl::find(const LChar* matchString, unsigned start)
837823
// delta is the number of additional times to test; delta == 0 means test only once.
838824
unsigned delta = searchLength - matchLength;
839825

840-
// Optimization 2: keep a running hash of the strings,
826+
// Optimization: keep a running hash of the strings,
841827
// only call equal if the hashes match.
842828

843829
if (is8Bit()) {
@@ -881,6 +867,19 @@ size_t StringImpl::find(const LChar* matchString, unsigned start)
881867
return start + i;
882868
}
883869

870+
size_t StringImpl::reverseFind(const LChar* matchString, unsigned matchLength, unsigned start)
871+
{
872+
ASSERT(matchLength);
873+
874+
unsigned length = this->length();
875+
if (matchLength > length)
876+
return notFound;
877+
878+
if (is8Bit())
879+
return reverseFindInner(characters8(), matchString, start, length, matchLength);
880+
return reverseFindInner(characters16(), matchString, start, length, matchLength);
881+
}
882+
884883
size_t StringImpl::find(StringView matchString)
885884
{
886885
// Check for null string to match against

Source/WTF/wtf/text/StringImpl.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,14 +432,17 @@ class StringImpl : private StringImplShape {
432432
size_t find(UChar character, unsigned start = 0);
433433
template<typename CodeUnitMatchFunction, std::enable_if_t<std::is_invocable_r_v<bool, CodeUnitMatchFunction, UChar>>* = nullptr>
434434
size_t find(CodeUnitMatchFunction, unsigned start = 0);
435-
WTF_EXPORT_PRIVATE size_t find(const LChar*, unsigned start = 0);
435+
ALWAYS_INLINE size_t find(ASCIILiteral literal, unsigned start = 0) { return find(literal.characters8(), literal.length(), start); }
436+
size_t find(const char*, unsigned start = 0) = delete;
436437
WTF_EXPORT_PRIVATE size_t find(StringView);
437438
WTF_EXPORT_PRIVATE size_t find(StringView, unsigned start);
438439
WTF_EXPORT_PRIVATE size_t findIgnoringASCIICase(StringView) const;
439440
WTF_EXPORT_PRIVATE size_t findIgnoringASCIICase(StringView, unsigned start) const;
440441

441442
WTF_EXPORT_PRIVATE size_t reverseFind(UChar, unsigned start = MaxLength);
442443
WTF_EXPORT_PRIVATE size_t reverseFind(StringView, unsigned start = MaxLength);
444+
ALWAYS_INLINE size_t reverseFind(ASCIILiteral literal, unsigned start = MaxLength) { return reverseFind(literal.characters8(), literal.length(), start); }
445+
size_t reverseFind(const char*, unsigned start = MaxLength) = delete;
443446

444447
WTF_EXPORT_PRIVATE bool startsWith(StringView) const;
445448
WTF_EXPORT_PRIVATE bool startsWithIgnoringASCIICase(StringView) const;
@@ -495,6 +498,9 @@ class StringImpl : private StringImplShape {
495498
template<typename> static size_t maxInternalLength();
496499
template<typename> static size_t tailOffset();
497500

501+
WTF_EXPORT_PRIVATE size_t find(const LChar*, unsigned length, unsigned start);
502+
WTF_EXPORT_PRIVATE size_t reverseFind(const LChar*, unsigned length, unsigned start);
503+
498504
bool requiresCopy() const;
499505
template<typename T> const T* tailPointer() const;
500506
template<typename T> T* tailPointer();

Source/WTF/wtf/text/StringView.cpp

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,34 @@ size_t StringView::find(StringView matchString, unsigned start) const
109109
return findCommon(*this, matchString, start);
110110
}
111111

112+
size_t StringView::find(const LChar* match, unsigned matchLength, unsigned start) const
113+
{
114+
ASSERT(matchLength);
115+
auto length = this->length();
116+
if (start > length)
117+
return notFound;
118+
119+
unsigned searchLength = length - start;
120+
if (matchLength > searchLength)
121+
return notFound;
122+
123+
if (is8Bit())
124+
return findInner(characters8() + start, match, start, searchLength, matchLength);
125+
return findInner(characters16() + start, match, start, searchLength, matchLength);
126+
}
127+
128+
size_t StringView::reverseFind(const LChar* match, unsigned matchLength, unsigned start) const
129+
{
130+
ASSERT(matchLength);
131+
auto length = this->length();
132+
if (matchLength > length)
133+
return notFound;
134+
135+
if (is8Bit())
136+
return reverseFindInner(characters8(), match, start, length, matchLength);
137+
return reverseFindInner(characters16(), match, start, length, matchLength);
138+
}
139+
112140
void StringView::SplitResult::Iterator::findNextSubstring()
113141
{
114142
for (size_t separatorPosition; (separatorPosition = m_result.m_string.find(m_result.m_separator, m_position)) != notFound; ++m_position) {
@@ -343,11 +371,6 @@ bool equalRespectingNullity(StringView a, StringView b)
343371
return equalCommon(a, b);
344372
}
345373

346-
bool StringView::contains(const char* string) const
347-
{
348-
return find(string) != notFound;
349-
}
350-
351374
StringView StringView::stripWhiteSpace() const
352375
{
353376
return stripLeadingAndTrailingMatchedCharacters(isASCIISpace<UChar>);

Source/WTF/wtf/text/StringView.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,13 @@ class StringView final {
146146
size_t find(UChar, unsigned start = 0) const;
147147
template<typename CodeUnitMatchFunction, std::enable_if_t<std::is_invocable_r_v<bool, CodeUnitMatchFunction, UChar>>* = nullptr>
148148
size_t find(CodeUnitMatchFunction&&, unsigned start = 0) const;
149+
ALWAYS_INLINE size_t find(ASCIILiteral literal, unsigned start = 0) const { return find(literal.characters8(), literal.length(), start); }
150+
size_t find(const char*, unsigned start = 0) const = delete;
149151
WTF_EXPORT_PRIVATE size_t find(StringView, unsigned start = 0) const;
150152

151153
size_t reverseFind(UChar, unsigned index = std::numeric_limits<unsigned>::max()) const;
154+
ALWAYS_INLINE size_t reverseFind(ASCIILiteral literal, unsigned start = std::numeric_limits<unsigned>::max()) const { return reverseFind(literal.characters8(), literal.length(), start); }
155+
size_t reverseFind(const char*, unsigned start = std::numeric_limits<unsigned>::max()) const = delete;
152156
WTF_EXPORT_PRIVATE size_t reverseFind(StringView, unsigned start = std::numeric_limits<unsigned>::max()) const;
153157

154158
WTF_EXPORT_PRIVATE size_t findIgnoringASCIICase(StringView) const;
@@ -161,8 +165,9 @@ class StringView final {
161165
bool contains(UChar) const;
162166
template<typename CodeUnitMatchFunction, std::enable_if_t<std::is_invocable_r_v<bool, CodeUnitMatchFunction, UChar>>* = nullptr>
163167
bool contains(CodeUnitMatchFunction&&) const;
164-
bool contains(StringView string) const { return find(string, 0) != notFound; }
165-
WTF_EXPORT_PRIVATE bool contains(const char*) const;
168+
bool contains(ASCIILiteral literal) const { return find(literal) != notFound; }
169+
bool contains(const char*) const = delete;
170+
bool contains(StringView string) const { return find(string) != notFound; }
166171

167172
WTF_EXPORT_PRIVATE bool containsIgnoringASCIICase(StringView) const;
168173
WTF_EXPORT_PRIVATE bool containsIgnoringASCIICase(StringView, unsigned start) const;
@@ -191,6 +196,9 @@ class StringView final {
191196
void initialize(const LChar*, unsigned length);
192197
void initialize(const UChar*, unsigned length);
193198

199+
WTF_EXPORT_PRIVATE size_t find(const LChar* match, unsigned matchLength, unsigned start) const;
200+
WTF_EXPORT_PRIVATE size_t reverseFind(const LChar* match, unsigned matchLength, unsigned start) const;
201+
194202
template<typename CharacterType, typename MatchedCharacterPredicate>
195203
StringView stripLeadingAndTrailingMatchedCharacters(const CharacterType*, const MatchedCharacterPredicate&) const;
196204

Source/WTF/wtf/text/WTFString.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,11 @@ class String final {
162162

163163
template<typename CodeUnitMatchFunction, std::enable_if_t<std::is_invocable_r_v<bool, CodeUnitMatchFunction, UChar>>* = nullptr>
164164
size_t find(CodeUnitMatchFunction matchFunction, unsigned start = 0) const { return m_impl ? m_impl->find(matchFunction, start) : notFound; }
165-
size_t find(const LChar* string, unsigned start = 0) const { return m_impl ? m_impl->find(string, start) : notFound; }
165+
size_t find(ASCIILiteral literal, unsigned start = 0) const { return m_impl ? m_impl->find(literal, start) : notFound; }
166166

167167
// Find the last instance of a single character or string.
168168
size_t reverseFind(UChar character, unsigned start = MaxLength) const { return m_impl ? m_impl->reverseFind(character, start) : notFound; }
169+
size_t reverseFind(ASCIILiteral literal, unsigned start = MaxLength) const { return m_impl ? m_impl->reverseFind(literal, start) : notFound; }
169170
size_t reverseFind(StringView, unsigned start = MaxLength) const;
170171

171172
WTF_EXPORT_PRIVATE Vector<UChar> charactersWithNullTermination() const;
@@ -174,7 +175,7 @@ class String final {
174175
WTF_EXPORT_PRIVATE UChar32 characterStartingAt(unsigned) const;
175176

176177
bool contains(UChar character) const { return find(character) != notFound; }
177-
bool contains(const LChar* string) const { return find(string) != notFound; }
178+
bool contains(ASCIILiteral literal) const { return find(literal) != notFound; }
178179
bool contains(StringView) const;
179180
template<typename CodeUnitMatchFunction, std::enable_if_t<std::is_invocable_r_v<bool, CodeUnitMatchFunction, UChar>>* = nullptr>
180181
bool contains(CodeUnitMatchFunction matchFunction) const { return find(matchFunction, 0) != notFound; }

Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ RefPtr<DOMFormData> FetchBodyConsumer::packageFormData(ScriptExecutionContext* c
144144
size_t contentDispositionBegin = header.find(contentDispositionCharacters);
145145
if (contentDispositionBegin == notFound)
146146
return false;
147-
size_t contentDispositionEnd = header.find("\r\n", contentDispositionBegin);
147+
size_t contentDispositionEnd = header.find("\r\n"_s, contentDispositionBegin);
148148
size_t contentDispositionParametersBegin = header.find(';', contentDispositionBegin + strlen(contentDispositionCharacters));
149149
if (contentDispositionParametersBegin != notFound)
150150
contentDispositionParametersBegin++;
@@ -163,7 +163,7 @@ RefPtr<DOMFormData> FetchBodyConsumer::packageFormData(ScriptExecutionContext* c
163163
size_t contentTypePrefixLength = strlen(contentTypeCharacters);
164164
size_t contentTypeBegin = header.find(contentTypeCharacters);
165165
if (contentTypeBegin != notFound) {
166-
size_t contentTypeEnd = header.find("\r\n", contentTypeBegin);
166+
size_t contentTypeEnd = header.find("\r\n"_s, contentTypeBegin);
167167
contentType = StringView(header).substring(contentTypeBegin + contentTypePrefixLength, contentTypeEnd - contentTypeBegin - contentTypePrefixLength).stripLeadingAndTrailingMatchedCharacters(isHTTPSpace).toString();
168168
}
169169

0 commit comments

Comments
 (0)