Skip to content

Commit b7cce06

Browse files
darinadlercalvaris
authored andcommitted
Streamline handling of null-terminated strings to improve clarity and safety
rdar://165305546 https://bugs.webkit.org/show_bug.cgi?id=303027 Reviewed by Sam Weinig. Eliminated other members of the unsafeSpan function family, leaving only unsafeSpan and unsafeSpanIncludingNullTerminator. Eliminated some functions that take null-terminated strings, such as String::createFromCString. Changed callers to safe interfaces that pass lengths and sizes instead or to call unsafeSpan. Redid the UTF-8 span literal operator so we can use it in constant expressions. Syntax is now u8""_span instead of ""_spanChar8. Simplified test code that was unnecessarily using null-terminated strings to instead use ASCIILiteral or similar. Also used toNSData in test code rather than toNSDataNoCopy; the "no copy" optimization is unnecessary for tests. * Source/JavaScriptCore/API/JSStringRef.cpp: (JSStringCreateWithUTF8CString): Use unsafeSpan. Use conversion from UTF-8 built into the String class. Take advantage of null handling built into the function so we don't need a special case for the null pointer. * Source/JavaScriptCore/API/JSValue.mm: (createStructHandlerMap): Use unsafeSpan. * Source/JavaScriptCore/runtime/Identifier.h: Removed overloads of the == operator and the equal function that take null-terminated strings. (JSC::Identifier::equal): * Source/JavaScriptCore/runtime/Options.cpp: (JSC::OptionsHelper::Option::dump const): Use unsafeSpan. * Source/JavaScriptCore/wasm/WasmParser.h: (JSC::Wasm::ParserBase::consumeUTF8String): Use byteCast. * Source/WTF/wtf/FileSystem.cpp: (WTF::FileSystemImpl::fromStdFileSystemPath): Use unsafeSpan. * Source/WTF/wtf/text/ASCIILiteral.h: Added u8""_span. Removed ""_spanChar8. * Source/WTF/wtf/text/StringCommon.h: Deleted the unsafeSpan overload that takes const Latin1Character*. (WTF::unsafeSpan8): Deleted. (WTF::unsafeSpanChar8): Deleted. (WTF::unsafeSpan8IncludingNullTerminator): Deleted. * Source/WTF/wtf/text/StringConcatenate.h: Deleted the StringTypeAdapter that takes const Latin1Character*. * Source/WTF/wtf/text/StringImpl.h: Use unsafeSpan. (WTF::StringImpl::createFromCString): Deleted. * Source/WTF/wtf/text/StringView.h: Use unsafeSpan. Replaced the equal function that takes const Latin1Character* with one that takes span<const Latin1Character>. * Source/WTF/wtf/text/WTFString.cpp: (WTF::String::String): Use unsafeSpan. * Source/WTF/wtf/text/WTFString.h: Use unsafeSpan. Some updates to the fromUTF8 family of functions, clarifying deprecation. * Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp: (WebCore::GraphicsContextGLANGLE::initialize): Use unsafeSpan. * Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm: (WebCore::initializeEGLDisplay): Use unsafeSpan. (WebCore::GraphicsContextGLCocoa::platformInitializeContext): Ditto. * Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp: (WebCore::FontPlatformData::familyName const): Use unsafeSpan. * Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp: (WebCore::TrackPrivateBaseGStreamer::TrackPrivateBaseGStreamer): Use unsafeSpan. (WebCore::TrackPrivateBaseGStreamer::setPad): Ditto. (WebCore::TrackPrivateBaseGStreamer::getLanguageCode): Ditto. (WebCore::TrackPrivateBaseGStreamer::notifyTrackOfStreamChanged): Ditto. (WebCore::TrackPrivateBaseGStreamer::updateTrackIDFromTags): Ditto. * Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp: (WebCore::AppendPipeline::recycleTrackForPad): Use unsafeSpan. (WebCore::serializeLowercase): Moved this function up in the file, changed it to return ASCIILiteral, and made it a non-member function so it can be internal to the file rather than in the header. (WebCore::AppendPipeline::Track::emplaceOptionalElementsForFormat): Use serializeLowercase. * Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.h: Removed now-unused streamTypeToStringLower. * Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp: (webkit_web_view_load_plain_text): Use unsafeSpan. * Source/WebKit/UIProcess/gtk/SystemSettingsManagerProxyGtk.cpp: (WebKit::SystemSettingsManagerProxy::updateFontProperties): Use unsafeSpan. * Source/WebKit/WebProcess/GPU/media/RemoteVideoCodecFactory.cpp: (WebKit::RemoteVideoCodecFactory::createEncoder): Use byteCast. * Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/GObjectEventListener.cpp: (WebKit::GObjectEventListener::GObjectEventListener): Store event type as m_eventType AtomString instead of m_domEventName CString, previously we converted it to an AtomString any time it is used. Also, used the term event type from the DOM rather than coining a different name for the same concept. (WebKit::GObjectEventListener::gobjectDestroyed): Use m_eventType. * Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/GObjectEventListener.h: (WebKit::GObjectEventListener::addEventListener): Use m_eventType instead of converting to AtomString. (WebKit::GObjectEventListener::removeEventListener): Ditto. * Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::accessibilityFocusedUIElement): Use unsafeSpanIncludingNullTerminator. * Tools/TestWebKitAPI/Tests/WTF/CString.cpp: (TEST(WTF, CStringViewASCIICaseConversions)): Use u8""_span. * Tools/TestWebKitAPI/Tests/WTF/StringBuilder.cpp: (TestWebKitAPI::TEST(StringBuilderTest, Append)): Use u8""_span. * Tools/TestWebKitAPI/Tests/WTF/StringCommon.cpp: (TestWebKitAPI::TEST(WTF_StringCommon, Equal)): Use u8""_span. (TestWebKitAPI::TEST(WTF_StringCommon, EqualIgnoringASCIICase)): Ditto. (TestWebKitAPI::TEST(WTF_StringCommon, StartsWith)): Ditto. (TestWebKitAPI::TEST(WTF_StringCommon, EndsWith)): Ditto. (TestWebKitAPI::TEST(WTF_StringCommon, Find)): Ditto. (TestWebKitAPI::TEST(WTF_StringCommon, ReverseFind)): Ditto. (TestWebKitAPI::TEST(WTF_StringCommon, Contains)): Ditto. (TestWebKitAPI::TEST(WTF_StringCommon, StartsWithLettersIgnoringASCIICase)): Ditto. (TestWebKitAPI::TEST(WTF_StringCommon, EndsWithLettersIgnoringASCIICase)): Ditto. (TestWebKitAPI::TEST(WTF_StringCommon, FindIgnoringASCIICase)): Ditto. (TestWebKitAPI::TEST(WTF_StringCommon, ContainsIgnoringASCIICase)): Ditto. (TestWebKitAPI::TEST(WTF_StringCommon, CharactersAreAllASCII)): Ditto. * Tools/TestWebKitAPI/Tests/WebKitCocoa/BundleEditingDelegatePlugIn.mm: (-[BundleEditingDelegatePlugIn _webProcessPlugInBrowserContextController:pasteboardDataForRange:]): Use [NSData dataUsingEncoding:]. * Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm: (-[PSONScheme initWithBytes:]): Use ASCIILiteral. (-[PSONScheme addMappingFromURLString:toData:]): Ditto. (-[PSONScheme webView:startURLSchemeTask:]): Ditto. ((ProcessSwap, HistoryNavigationToFragmentURL)): Ditto. ((ProcessSwap, PolicyCancelAfterServerRedirect)): Ditto. ((ProcessSwap, SameOriginSystemPreview)): Ditto. ((ProcessSwap, SessionStorage)): Ditto. ((ProcessSwap, ReuseSuspendedProcessEvenIfPageCacheFails)): Ditto. ((ProcessSwap, HistoryItemIDConfusion)): Ditto. ((ProcessSwap, MainFramesOnly)): Ditto. ((ProcessSwap, MediaTypeAfterSwap)): Ditto. ((ProcessSwap, NavigateCrossSiteBeforePageLoadEnd)): Ditto. ((ProcessSwap, PageShowHide)): Ditto. ((ProcessSwap, LoadUnload)): Ditto. ((ProcessSwap, SameOriginBlobNavigation)): Ditto. ((ProcessSwap, NavigateToDataURLThenBack)): Ditto. ((ProcessSwap, SwapOnFormSubmission)): Ditto. ((ProcessSwap, OpenerLinkAfterAPIControlledProcessSwappingOfOpener)): Ditto. ((ProcessSwap, NavigateCrossOriginWithOpener)): Ditto. ((ProcessSwap, ContentBlockingAfterProcessSwap)): Ditto. ((ProcessSwap, ContentExtensionBlocksMainLoadThenReloadWithoutExtensions)): Ditto. ((ProcessSwap, GetUserMediaCaptureState)): Ditto. ((ProcessSwap, PassMinimumDeviceWidthOnNewWebView)): Ditto. ((ProcessSwap, ResizeWebViewDuringCrossSiteProvisionalNavigation)): Ditto. * Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm: (-[ServiceWorkerSchemeHandler webView:startURLSchemeTask:]): Use unsafeSpan. * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm: (mainBytesData): Added. (TEST(URLSchemeHandler, Basic)): Use ASCIILiteral. (TEST(URLSchemeHandler, BasicWithHTTPS)): Ditto. (TEST(URLSchemeHandler, BasicWithAsyncPolicyDelegate)): Ditto. (TEST(URLSchemeHandler, NoMIMEType)): Ditto. (-[SyncScheme webView:startURLSchemeTask:]): Ditto. (-[SyncErrorScheme webView:startURLSchemeTask:]): Ditto. * Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm: (-[DataMappingSchemeHandler addMappingFromURLString:toData:]): Use ASCIILiteral. ((WebpagePreferences, WebsitePoliciesCustomUserAgent)): Ditto. * Tools/TestWebKitAPI/Tests/mac/WebViewIconLoading.mm: (mainResourceData): Use ASCIILiteral. (imageFromData): Ditto. (TestWebKitAPI::TEST(WebKitLegacy, IconLoadingDelegateDefaultFirst)): Ditto. (TestWebKitAPI::TEST(WebKitLegacy, IconLoadingDelegateCustomFirst)): Ditto. Canonical link: https://commits.webkit.org/303520@main Signed-off-by: Xabier Rodriguez Calvar <calvaris@igalia.com>
1 parent 95e3e29 commit b7cce06

79 files changed

Lines changed: 368 additions & 400 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Source/JavaScriptCore/API/JSStringRef.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ JSStringRef JSStringCreateWithUTF8CString(const char* string)
4545
{
4646
JSC::initialize();
4747
if (string) {
48-
auto stringSpan = span8(string);
48+
auto stringSpan = byteCast<char8_t>(unsafeSpan(string));
4949
Vector<char16_t, 1024> buffer(stringSpan.size());
5050
auto result = WTF::Unicode::convert(spanReinterpretCast<const char8_t>(stringSpan), buffer.mutableSpan());
5151
if (result.code == WTF::Unicode::ConversionResultCode::Success) {
5252
if (result.isAllASCII)
53-
return &OpaqueJSString::create(stringSpan).leakRef();
53+
return &OpaqueJSString::create(byteCast<Latin1Character>(stringSpan)).leakRef();
5454
return &OpaqueJSString::create(result.buffer).leakRef();
5555
}
5656
}

Source/JavaScriptCore/API/JSValue.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,8 +1281,8 @@ - (JSValue *)initWithValue:(JSValueRef)value inContext:(JSContext *)context
12811281
if (strcmp(idType, "@") != 0)
12821282
return;
12831283
{
1284-
auto type = adoptSystem<char[]>(method_copyArgumentType(method, 2));
1285-
structHandlers->add(StringImpl::createFromCString(type.get()), (StructTagHandler) { selector, 0 });
1284+
auto type = adoptSystem<char[]>(method_copyArgumentType(method, 2));
1285+
structHandlers->add(byteCast<Latin1Character>(unsafeSpan(type.get()), (StructTagHandler) { selector, 0 });
12861286
}
12871287
});
12881288

Source/JavaScriptCore/API/glib/JSCCallbackFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ JSObjectRef JSCCallbackFunction::construct(JSContextRef callerContext, size_t ar
228228
*exception = toRef(JSC::createTypeError(toJS(jsContext), "constructor returned null"_s));
229229
break;
230230
default:
231-
*exception = toRef(JSC::createTypeError(toJS(jsContext), makeString("invalid type "_s, span(g_type_name(G_VALUE_TYPE(&returnValue))), " returned by constructor"_s)));
231+
*exception = toRef(JSC::createTypeError(toJS(jsContext), makeString("invalid type "_s, unsafeSpan(g_type_name(G_VALUE_TYPE(&returnValue))), " returned by constructor"_s)));
232232
break;
233233
}
234234
g_value_unset(&returnValue);

Source/JavaScriptCore/API/glib/JSCContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ JSValueRef jscContextGValueToJSValue(JSCContext* context, const GValue* value, J
467467
break;
468468
}
469469

470-
*exception = toRef(JSC::createTypeError(globalObject, makeString("unsupported type "_s, span(g_type_name(G_VALUE_TYPE(value))))));
470+
*exception = toRef(JSC::createTypeError(globalObject, makeString("unsupported type "_s, unsafeSpan(g_type_name(G_VALUE_TYPE(value))))));
471471
return JSValueMakeUndefined(priv->jsContext.get());
472472
}
473473

@@ -587,7 +587,7 @@ void jscContextJSValueToGValue(JSCContext* context, JSValueRef jsValue, GType ty
587587
case G_TYPE_INTERFACE:
588588
case G_TYPE_VARIANT:
589589
default:
590-
*exception = toRef(JSC::createTypeError(globalObject, makeString("unsupported type "_s, span(g_type_name(G_VALUE_TYPE(value))))));
590+
*exception = toRef(JSC::createTypeError(globalObject, makeString("unsupported type "_s, unsafeSpan(g_type_name(G_VALUE_TYPE(value))))));
591591
break;
592592
}
593593
}

Source/JavaScriptCore/API/glib/JSCValue.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ JSCValue* jsc_value_new_array(JSCContext* context, GType firstItemType, ...)
503503
G_VALUE_COLLECT_INIT(&item, itemType, args, G_VALUE_NOCOPY_CONTENTS, &error.outPtr());
504504
WTF_ALLOW_UNSAFE_BUFFER_USAGE_END
505505
if (error) {
506-
exception = toRef(JSC::createTypeError(globalObject, makeString("failed to collect array item: "_s, span(error.get()))));
506+
exception = toRef(JSC::createTypeError(globalObject, makeString("failed to collect array item: "_s, unsafeSpan(error.get()))));
507507
jscContextHandleExceptionIfNeeded(context, exception);
508508
jsArray = nullptr;
509509
break;
@@ -905,7 +905,7 @@ static GRefPtr<JSCValue> jscValueCallFunction(JSCValue* value, JSObjectRef funct
905905
G_VALUE_COLLECT_INIT(&parameter, parameterType, args, G_VALUE_NOCOPY_CONTENTS, &error.outPtr());
906906
WTF_ALLOW_UNSAFE_BUFFER_USAGE_END
907907
if (error) {
908-
exception = toRef(JSC::createTypeError(globalObject, makeString("failed to collect function paramater: "_s, span(error.get()))));
908+
exception = toRef(JSC::createTypeError(globalObject, makeString("failed to collect function paramater: "_s, unsafeSpan(error.get()))));
909909
jscContextHandleExceptionIfNeeded(priv->context.get(), exception);
910910
return adoptGRef(jsc_value_new_undefined(priv->context.get()));
911911
}

Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ RegisterID* RegExpNode::emitBytecode(BytecodeGenerator& generator, RegisterID* d
168168
if (regExp->isValid())
169169
return generator.emitNewRegExp(generator.finalDestination(dst), regExp);
170170

171-
auto& message = generator.parserArena().identifierArena().makeIdentifier(generator.vm(), span8(regExp->errorMessage()));
171+
auto& message = generator.parserArena().identifierArena().makeIdentifier(generator.vm(), byteCast<Latin1Character>(unsafeSpan(regExp->errorMessage())));
172172
generator.emitThrowStaticError(ErrorTypeWithExtension::SyntaxError, message);
173173
return generator.emitLoad(generator.finalDestination(dst), jsUndefined());
174174
}

Source/JavaScriptCore/runtime/Error.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,13 @@ JSObject* createTypeErrorCopy(JSGlobalObject* globalObject, JSValue error)
291291

292292
String makeDOMAttributeGetterTypeErrorMessage(const char* interfaceName, const String& attributeName)
293293
{
294-
auto interfaceNameSpan = span(interfaceName);
294+
auto interfaceNameSpan = unsafeSpan(interfaceName);
295295
return makeString("The "_s, interfaceNameSpan, '.', attributeName, " getter can only be used on instances of "_s, interfaceNameSpan);
296296
}
297297

298298
String makeDOMAttributeSetterTypeErrorMessage(const char* interfaceName, const String& attributeName)
299299
{
300-
auto interfaceNameSpan = span(interfaceName);
300+
auto interfaceNameSpan = unsafeSpan(interfaceName);
301301
return makeString("The "_s, interfaceNameSpan, '.', attributeName, " setter can only be used on instances of "_s, interfaceNameSpan);
302302
}
303303

Source/JavaScriptCore/runtime/Identifier.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,7 @@ class Identifier {
144144
bool isPrivateName() const { return isSymbol() && static_cast<const SymbolImpl*>(impl())->isPrivate(); }
145145

146146
friend bool operator==(const Identifier&, const Identifier&);
147-
friend bool operator==(const Identifier&, const Latin1Character*);
148-
friend bool operator==(const Identifier&, const char*);
149147

150-
static bool equal(const StringImpl*, const Latin1Character*);
151-
static inline bool equal(const StringImpl* a, const char* b) { return Identifier::equal(a, byteCast<Latin1Character>(b)); };
152148
static bool equal(const StringImpl*, std::span<const Latin1Character>);
153149
static bool equal(const StringImpl*, std::span<const char16_t>);
154150
static bool equal(const StringImpl* a, const StringImpl* b) { return ::equal(a, b); }
@@ -175,7 +171,6 @@ class Identifier {
175171
{ }
176172

177173
static bool equal(const Identifier& a, const Identifier& b) { return a.m_string.impl() == b.m_string.impl(); }
178-
static bool equal(const Identifier& a, const Latin1Character* b) { return equal(a.m_string.impl(), b); }
179174

180175
template <typename T> static Ref<AtomStringImpl> add(VM&, std::span<const T>);
181176
static Ref<AtomStringImpl> add8(VM&, std::span<const char16_t>);
@@ -228,21 +223,6 @@ inline bool operator==(const Identifier& a, const Identifier& b)
228223
return Identifier::equal(a, b);
229224
}
230225

231-
inline bool operator==(const Identifier& a, const Latin1Character* b)
232-
{
233-
return Identifier::equal(a, b);
234-
}
235-
236-
inline bool operator==(const Identifier& a, const char* b)
237-
{
238-
return Identifier::equal(a, byteCast<Latin1Character>(b));
239-
}
240-
241-
inline bool Identifier::equal(const StringImpl* r, const Latin1Character* s)
242-
{
243-
return WTF::equal(r, s);
244-
}
245-
246226
inline bool Identifier::equal(const StringImpl* r, std::span<const Latin1Character> s)
247227
{
248228
return WTF::equal(r, s);

Source/JavaScriptCore/runtime/Options.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ std::optional<T> parse(const char* string);
207207
template<>
208208
std::optional<OptionsStorage::Bool> parse(const char* string)
209209
{
210-
auto span = WTF::span(string);
210+
auto span = WTF::unsafeSpan(string);
211211
if (equalLettersIgnoringASCIICase(span, "true"_s) || equalLettersIgnoringASCIICase(span, "yes"_s) || !strcmp(string, "1"))
212212
return true;
213213
if (equalLettersIgnoringASCIICase(span, "false"_s) || equalLettersIgnoringASCIICase(span, "no"_s) || !strcmp(string, "0"))
@@ -278,7 +278,7 @@ std::optional<OptionsStorage::OptionString> parse(const char* string)
278278
template<>
279279
std::optional<OptionsStorage::GCLogLevel> parse(const char* string)
280280
{
281-
auto span = WTF::span(string);
281+
auto span = WTF::unsafeSpan(string);
282282
if (equalLettersIgnoringASCIICase(span, "none"_s) || equalLettersIgnoringASCIICase(span, "no"_s) || equalLettersIgnoringASCIICase(span, "false"_s) || !strcmp(string, "0"))
283283
return GCLogging::None;
284284

@@ -296,7 +296,7 @@ std::optional<OptionsStorage::OSLogType> parse(const char* string)
296296
{
297297
std::optional<OptionsStorage::OSLogType> result;
298298

299-
auto span = WTF::span(string);
299+
auto span = WTF::unsafeSpan(string);
300300
if (equalLettersIgnoringASCIICase(span, "none"_s) || equalLettersIgnoringASCIICase(span, "false"_s) || !strcmp(string, "0"))
301301
result = OSLogType::None;
302302
else if (equalLettersIgnoringASCIICase(span, "true"_s) || !strcmp(string, "1"))
@@ -428,7 +428,7 @@ bool Options::overrideAliasedOptionWithHeuristic(const char* name)
428428
if (!stringValue)
429429
return false;
430430

431-
auto aliasedOption = makeString(span(&name[4]), '=', span(stringValue));
431+
auto aliasedOption = makeString(unsafeSpan(&name[4]), '=', unsafeSpan(stringValue));
432432
if (Options::setOption(aliasedOption.utf8().data()))
433433
return true;
434434

@@ -1262,7 +1262,7 @@ bool Options::setAliasedOption(const char* arg, bool verify)
12621262
&& !strncasecmp(arg, #aliasedName_, equalStr - arg)) { \
12631263
auto unaliasedOption = String::fromLatin1(#unaliasedName_); \
12641264
if (equivalence == SameOption) \
1265-
unaliasedOption = makeString(unaliasedOption, span(equalStr)); \
1265+
unaliasedOption = makeString(unaliasedOption, unsafeSpan(equalStr)); \
12661266
else { \
12671267
ASSERT(equivalence == InvertedOption); \
12681268
auto invertedValueStr = invertBoolOptionValue(equalStr + 1); \
@@ -1439,10 +1439,10 @@ void Option::dump(StringBuilder& builder) const
14391439
builder.append(m_int32);
14401440
break;
14411441
case Options::Type::OptionRange:
1442-
builder.append(span(m_optionRange.rangeString()));
1442+
builder.append(unsafeSpan(m_optionRange.rangeString()));
14431443
break;
14441444
case Options::Type::OptionString:
1445-
builder.append('"', m_optionString ? span8(m_optionString) : ""_span, '"');
1445+
builder.append('"', m_optionString ? byteCast<Latin1Character>(unsafeSpan(m_optionString)) : ""_span, '"');
14461446
break;
14471447
case Options::Type::GCLogLevel:
14481448
builder.append(m_gcLogLevel);

Source/JavaScriptCore/runtime/RegExp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ String RegExp::escapedPattern() const
683683

684684
String RegExp::toSourceString() const
685685
{
686-
return makeString('/', escapedPattern(), '/', span(Yarr::flagsString(flags()).data()));
686+
return makeString('/', escapedPattern(), '/', unsafeSpan(Yarr::flagsString(flags()).data()));
687687
}
688688

689689
} // namespace JSC

0 commit comments

Comments
 (0)