Title: [295335] trunk
- Revision
- 295335
- Author
- [email protected]
- Date
- 2022-06-07 02:23:10 -0700 (Tue, 07 Jun 2022)
Log Message
Validate top origin in ServiceWorkerRegistrationKey::fromDatabaseKey
https://bugs.webkit.org/show_bug.cgi?id=241221
rdar://problem/94280334
Patch by Youenn Fablet <[email protected]> on 2022-06-07
Reviewed by Chris Dumez.
When reading the top origin from file disk, let's validate it like we do with scope URL.
Covered by API tests.
* Source/WebCore/workers/service/ServiceWorkerRegistrationKey.cpp:
(WebCore::ServiceWorkerRegistrationKey::fromDatabaseKey):
* Tools/TestWebKitAPI/Tests/WebCore/ServiceWorkerRoutines.cpp:
(TEST):
Canonical link: https://commits.webkit.org/251354@main
Modified Paths
Diff
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationKey.cpp (295334 => 295335)
--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationKey.cpp 2022-06-07 07:16:12 UTC (rev 295334)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationKey.cpp 2022-06-07 09:23:10 UTC (rev 295335)
@@ -114,11 +114,19 @@
return std::nullopt;
}
+ auto scheme = StringView(key).left(first);
+ auto host = StringView(key).substring(first + 1, second - first - 1);
+
+ URL topOriginURL { makeString(scheme, "://", host) };
+ if (!topOriginURL.isValid())
+ return std::nullopt;
+
URL scope { key.substring(third + 1) };
if (!scope.isValid())
return std::nullopt;
- return ServiceWorkerRegistrationKey { { key.left(first), key.substring(first + 1, second - first - 1), shortPort }, WTFMove(scope) };
+ SecurityOriginData topOrigin { scheme.toString(), host.toString(), shortPort };
+ return ServiceWorkerRegistrationKey { WTFMove(topOrigin), WTFMove(scope) };
}
#if !LOG_DISABLED
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/ServiceWorkerRoutines.cpp (295334 => 295335)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/ServiceWorkerRoutines.cpp 2022-06-07 07:16:12 UTC (rev 295334)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/ServiceWorkerRoutines.cpp 2022-06-07 09:23:10 UTC (rev 295335)
@@ -32,4 +32,13 @@
{
auto key = WebCore::ServiceWorkerRegistrationKey::fromDatabaseKey("_http://test.org"_s);
EXPECT_FALSE(!!key);
+
+ key = WebCore::ServiceWorkerRegistrationKey::fromDatabaseKey("http_test.org_164645646_http://test.org"_s);
+ EXPECT_FALSE(!!key);
+
+ key = WebCore::ServiceWorkerRegistrationKey::fromDatabaseKey("??_test.org_443_http://test.org"_s);
+ EXPECT_FALSE(!!key);
+
+ key = WebCore::ServiceWorkerRegistrationKey::fromDatabaseKey("https_??_443_http://test.org"_s);
+ EXPECT_FALSE(!!key);
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes