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

Unified Diff: content/child/service_worker/service_worker_dispatcher.cc

Issue 342163005: ServiceWorker: Reject overly long scope/script URLs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix formatting nits Created 6 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/service_worker/service_worker_dispatcher.cc
diff --git a/content/child/service_worker/service_worker_dispatcher.cc b/content/child/service_worker/service_worker_dispatcher.cc
index 131b714acb6c5e7cecb8197590af6ca31e29daa2..936f5c84dc51d16975a3fcbfee72f53c845f321e 100644
--- a/content/child/service_worker/service_worker_dispatcher.cc
+++ b/content/child/service_worker/service_worker_dispatcher.cc
@@ -14,6 +14,7 @@
#include "content/child/thread_safe_sender.h"
#include "content/child/webmessageportchannel_impl.h"
#include "content/common/service_worker/service_worker_messages.h"
+#include "content/public/common/url_utils.h"
#include "third_party/WebKit/public/platform/WebServiceWorkerProviderClient.h"
#include "third_party/WebKit/public/web/WebSecurityOrigin.h"
@@ -78,6 +79,17 @@ void ServiceWorkerDispatcher::RegisterServiceWorker(
const GURL& script_url,
WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks) {
DCHECK(callbacks);
+
+ if (pattern.possibly_invalid_spec().size() > GetMaxURLChars() ||
+ script_url.possibly_invalid_spec().size() > GetMaxURLChars()) {
+ scoped_ptr<WebServiceWorkerProvider::WebServiceWorkerCallbacks>
+ owned_callbacks(callbacks);
+ scoped_ptr<WebServiceWorkerError> error(new WebServiceWorkerError(
+ WebServiceWorkerError::ErrorTypeSecurity, "URL too long"));
+ callbacks->onError(error.release());
+ return;
+ }
+
int request_id = pending_callbacks_.Add(callbacks);
thread_safe_sender_->Send(new ServiceWorkerHostMsg_RegisterServiceWorker(
CurrentWorkerId(), request_id, provider_id, pattern, script_url));
@@ -88,6 +100,16 @@ void ServiceWorkerDispatcher::UnregisterServiceWorker(
const GURL& pattern,
WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks) {
DCHECK(callbacks);
+
+ if (pattern.possibly_invalid_spec().size() > GetMaxURLChars()) {
+ scoped_ptr<WebServiceWorkerProvider::WebServiceWorkerCallbacks>
+ owned_callbacks(callbacks);
+ scoped_ptr<WebServiceWorkerError> error(new WebServiceWorkerError(
+ WebServiceWorkerError::ErrorTypeSecurity, "URL too long"));
+ callbacks->onError(error.release());
+ return;
+ }
+
int request_id = pending_callbacks_.Add(callbacks);
thread_safe_sender_->Send(new ServiceWorkerHostMsg_UnregisterServiceWorker(
CurrentWorkerId(), request_id, provider_id, pattern));
@@ -215,7 +237,7 @@ void ServiceWorkerDispatcher::OnRegistrationError(
if (!callbacks)
return;
- scoped_ptr<WebServiceWorkerError> error(
+ scoped_ptr<WebServiceWorkerError> error(
new WebServiceWorkerError(error_type, message));
callbacks->onError(error.release());
pending_callbacks_.Remove(request_id);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698