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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 return promise; 128 return promise;
129 } 129 }
130 130
131 KURL scriptURL = executionContext->completeURL(url); 131 KURL scriptURL = executionContext->completeURL(url);
132 scriptURL.removeFragmentIdentifier(); 132 scriptURL.removeFragmentIdentifier();
133 if (!documentOrigin->canRequest(scriptURL)) { 133 if (!documentOrigin->canRequest(scriptURL)) {
134 resolver->reject(DOMException::create(SecurityError, "The origin of the script must match the current origin.")); 134 resolver->reject(DOMException::create(SecurityError, "The origin of the script must match the current origin."));
135 return promise; 135 return promise;
136 } 136 }
137 137
138 if (!patternURL.string().startsWith(scriptURL.baseAsString())) {
139 resolver->reject(DOMException::create(SecurityError, "The scope must be under the directory of the script URL."));
140 return promise;
141 }
142
138 m_provider->registerServiceWorker(patternURL, scriptURL, new CallbackPromise Adapter<ServiceWorkerRegistration, ServiceWorkerError>(resolver)); 143 m_provider->registerServiceWorker(patternURL, scriptURL, new CallbackPromise Adapter<ServiceWorkerRegistration, ServiceWorkerError>(resolver));
139 144
140 return promise; 145 return promise;
141 } 146 }
142 147
143 class BooleanValue { 148 class BooleanValue {
144 public: 149 public:
145 typedef bool WebType; 150 typedef bool WebType;
146 static bool take(ScriptPromiseResolver* resolver, WebType* boolean) 151 static bool take(ScriptPromiseResolver* resolver, WebType* boolean)
147 { 152 {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 m_ready = createReadyProperty(); 262 m_ready = createReadyProperty();
258 263
259 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { 264 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) {
260 m_provider = client->provider(); 265 m_provider = client->provider();
261 if (m_provider) 266 if (m_provider)
262 m_provider->setClient(this); 267 m_provider->setClient(this);
263 } 268 }
264 } 269 }
265 270
266 } // namespace blink 271 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698