Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1404)

Unified Diff: Source/modules/serviceworkers/ServiceWorkerContainer.cpp

Issue 672383003: [ServiceWorker] Don't allow registration of the ServiceWorker scope outside the script directory. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/serviceworkers/ServiceWorkerContainer.cpp
diff --git a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
index 4ff54d1bd11d1b975e50308788614944896fb173..7967890dffcb968ba03c2ea8007ecbc647ba5452 100644
--- a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
+++ b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
@@ -135,6 +135,11 @@ ScriptPromise ServiceWorkerContainer::registerServiceWorker(ScriptState* scriptS
return promise;
}
+ if (!patternURL.string().startsWith(scriptURL.baseAsString())) {
+ resolver->reject(DOMException::create(SecurityError, "The scope must be under the directory of the script URL."));
+ return promise;
+ }
+
m_provider->registerServiceWorker(patternURL, scriptURL, new CallbackPromiseAdapter<ServiceWorkerRegistration, ServiceWorkerError>(resolver));
return promise;

Powered by Google App Engine
This is Rietveld 408576698