Title: [291730] trunk/Source
Revision
291730
Author
cdu...@apple.com
Date
2022-03-22 17:58:41 -0700 (Tue, 22 Mar 2022)

Log Message

Add URL::stringWithoutFragmentIdentifier() overload which returns a String instead of a StringView
https://bugs.webkit.org/show_bug.cgi?id=238221

Reviewed by Geoffrey Garen.

Source/WebCore:

* page/History.cpp:
(WebCore::History::stateObjectAdded):
* platform/network/BlobRegistryImpl.cpp:
(WebCore::BlobRegistryImpl::getBlobDataFromURL const):
(WebCore::BlobRegistryImpl::registerBlobURLHandle):
(WebCore::BlobRegistryImpl::unregisterBlobURLHandle):
(WebCore::blobURLWithoutFragment): Deleted.

Source/WTF:

* wtf/URL.cpp:
(WTF::URL::viewWithoutQueryOrFragmentIdentifier const):
(WTF::URL::viewWithoutFragmentIdentifier const):
(WTF::URL::stringWithoutFragmentIdentifier const):
(WTF::equalIgnoringFragmentIdentifier):
(WTF::URL::stringWithoutQueryOrFragmentIdentifier const): Deleted.
* wtf/URL.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (291729 => 291730)


--- trunk/Source/WTF/ChangeLog	2022-03-23 00:19:32 UTC (rev 291729)
+++ trunk/Source/WTF/ChangeLog	2022-03-23 00:58:41 UTC (rev 291730)
@@ -1,3 +1,18 @@
+2022-03-22  Chris Dumez  <cdu...@apple.com>
+
+        Add URL::stringWithoutFragmentIdentifier() overload which returns a String instead of a StringView
+        https://bugs.webkit.org/show_bug.cgi?id=238221
+
+        Reviewed by Geoffrey Garen.
+
+        * wtf/URL.cpp:
+        (WTF::URL::viewWithoutQueryOrFragmentIdentifier const):
+        (WTF::URL::viewWithoutFragmentIdentifier const):
+        (WTF::URL::stringWithoutFragmentIdentifier const):
+        (WTF::equalIgnoringFragmentIdentifier):
+        (WTF::URL::stringWithoutQueryOrFragmentIdentifier const): Deleted.
+        * wtf/URL.h:
+
 2022-03-22  Per Arne Vollan  <pvol...@apple.com>
 
         Enable content filtering in the Network process

Modified: trunk/Source/WTF/wtf/URL.cpp (291729 => 291730)


--- trunk/Source/WTF/wtf/URL.cpp	2022-03-23 00:19:32 UTC (rev 291729)
+++ trunk/Source/WTF/wtf/URL.cpp	2022-03-23 00:58:41 UTC (rev 291730)
@@ -708,7 +708,7 @@
     ));
 }
 
-StringView URL::stringWithoutQueryOrFragmentIdentifier() const
+StringView URL::viewWithoutQueryOrFragmentIdentifier() const
 {
     if (!m_isValid)
         return m_string;
@@ -716,7 +716,7 @@
     return StringView(m_string).left(pathEnd());
 }
 
-StringView URL::stringWithoutFragmentIdentifier() const
+StringView URL::viewWithoutFragmentIdentifier() const
 {
     if (!m_isValid)
         return m_string;
@@ -724,9 +724,17 @@
     return StringView(m_string).left(m_queryEnd);
 }
 
+String URL::stringWithoutFragmentIdentifier() const
+{
+    if (!m_isValid)
+        return m_string;
+
+    return m_string.left(m_queryEnd);
+}
+
 bool equalIgnoringFragmentIdentifier(const URL& a, const URL& b)
 {
-    return a.stringWithoutFragmentIdentifier() == b.stringWithoutFragmentIdentifier();
+    return a.viewWithoutFragmentIdentifier() == b.viewWithoutFragmentIdentifier();
 }
 
 bool protocolHostAndPortAreEqual(const URL& a, const URL& b)

Modified: trunk/Source/WTF/wtf/URL.h (291729 => 291730)


--- trunk/Source/WTF/wtf/URL.h	2022-03-23 00:19:32 UTC (rev 291729)
+++ trunk/Source/WTF/wtf/URL.h	2022-03-23 00:58:41 UTC (rev 291730)
@@ -117,8 +117,9 @@
 
     WTF_EXPORT_PRIVATE StringView queryWithLeadingQuestionMark() const;
     WTF_EXPORT_PRIVATE StringView fragmentIdentifierWithLeadingNumberSign() const;
-    WTF_EXPORT_PRIVATE StringView stringWithoutQueryOrFragmentIdentifier() const;
-    WTF_EXPORT_PRIVATE StringView stringWithoutFragmentIdentifier() const;
+    WTF_EXPORT_PRIVATE StringView viewWithoutQueryOrFragmentIdentifier() const;
+    WTF_EXPORT_PRIVATE StringView viewWithoutFragmentIdentifier() const;
+    WTF_EXPORT_PRIVATE String stringWithoutFragmentIdentifier() const;
 
     WTF_EXPORT_PRIVATE String protocolHostAndPort() const;
     WTF_EXPORT_PRIVATE String hostAndPort() const;

Modified: trunk/Source/WebCore/ChangeLog (291729 => 291730)


--- trunk/Source/WebCore/ChangeLog	2022-03-23 00:19:32 UTC (rev 291729)
+++ trunk/Source/WebCore/ChangeLog	2022-03-23 00:58:41 UTC (rev 291730)
@@ -1,3 +1,18 @@
+2022-03-22  Chris Dumez  <cdu...@apple.com>
+
+        Add URL::stringWithoutFragmentIdentifier() overload which returns a String instead of a StringView
+        https://bugs.webkit.org/show_bug.cgi?id=238221
+
+        Reviewed by Geoffrey Garen.
+
+        * page/History.cpp:
+        (WebCore::History::stateObjectAdded):
+        * platform/network/BlobRegistryImpl.cpp:
+        (WebCore::BlobRegistryImpl::getBlobDataFromURL const):
+        (WebCore::BlobRegistryImpl::registerBlobURLHandle):
+        (WebCore::BlobRegistryImpl::unregisterBlobURLHandle):
+        (WebCore::blobURLWithoutFragment): Deleted.
+
 2022-03-22  Sihui Liu  <sihui_...@apple.com>
 
         Check if origin can access storage in Storage API

Modified: trunk/Source/WebCore/page/History.cpp (291729 => 291730)


--- trunk/Source/WebCore/page/History.cpp	2022-03-23 00:19:32 UTC (rev 291729)
+++ trunk/Source/WebCore/page/History.cpp	2022-03-23 00:58:41 UTC (rev 291730)
@@ -208,7 +208,7 @@
     // We allow sandboxed documents, 'data:'/'file:' URLs, etc. to use 'pushState'/'replaceState' to modify the URL query and fragments.
     // See https://bugs.webkit.org/show_bug.cgi?id=183028 for the compatibility concerns.
     bool allowSandboxException = (documentSecurityOrigin.isLocal() || documentSecurityOrigin.isUnique())
-        && documentURL.stringWithoutQueryOrFragmentIdentifier() == fullURL.stringWithoutQueryOrFragmentIdentifier();
+        && documentURL.viewWithoutQueryOrFragmentIdentifier() == fullURL.viewWithoutQueryOrFragmentIdentifier();
 
     if (!allowSandboxException && !documentSecurityOrigin.canRequest(fullURL) && (fullURL.path() != documentURL.path() || fullURL.query() != documentURL.query()))
         return createBlockedURLSecurityErrorWithMessageSuffix("Paths and fragments must match for a sandboxed document.");

Modified: trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp (291729 => 291730)


--- trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp	2022-03-23 00:19:32 UTC (rev 291729)
+++ trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp	2022-03-23 00:58:41 UTC (rev 291730)
@@ -50,11 +50,6 @@
 
 namespace WebCore {
 
-static String blobURLWithoutFragment(const URL& url)
-{
-    return url.hasFragmentIdentifier() ? url.stringWithoutFragmentIdentifier().toString() : url.string();
-}
-
 BlobRegistryImpl::~BlobRegistryImpl() = default;
 
 static Ref<ResourceHandle> createBlobResourceHandle(const ResourceRequest& request, ResourceHandleClient* client)
@@ -235,7 +230,7 @@
 {
     ASSERT(isMainThread());
     if (url.hasFragmentIdentifier())
-        return m_blobs.get(url.stringWithoutFragmentIdentifier().toStringWithoutCopying());
+        return m_blobs.get(url.viewWithoutFragmentIdentifier().toStringWithoutCopying());
     return m_blobs.get(url.string());
 }
 
@@ -380,7 +375,7 @@
 
 void BlobRegistryImpl::registerBlobURLHandle(const URL& url)
 {
-    auto urlKey = blobURLWithoutFragment(url);
+    auto urlKey = url.stringWithoutFragmentIdentifier();
     if (m_blobs.contains(urlKey))
         m_blobReferences.add(urlKey);
 }
@@ -387,7 +382,7 @@
 
 void BlobRegistryImpl::unregisterBlobURLHandle(const URL& url)
 {
-    auto urlKey = blobURLWithoutFragment(url);
+    auto urlKey = url.stringWithoutFragmentIdentifier();
     if (m_blobReferences.remove(urlKey))
         m_blobs.remove(urlKey);
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to