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

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

Issue 675733003: Cache.put() validation of Request properties (Closed) Base URL: svn://svn.chromium.org/blink/trunk
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
« no previous file with comments | « LayoutTests/http/tests/serviceworker/cache-put-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/Cache.cpp
diff --git a/Source/modules/serviceworkers/Cache.cpp b/Source/modules/serviceworkers/Cache.cpp
index 0de7be13a0f0ad13824139799b4f8cbb41fbfa61..a1c4d8694c7cafba6ce2adaba371cf62efbffc6b 100644
--- a/Source/modules/serviceworkers/Cache.cpp
+++ b/Source/modules/serviceworkers/Cache.cpp
@@ -371,6 +371,12 @@ ScriptPromise Cache::deleteImpl(ScriptState* scriptState, Request* request, cons
ScriptPromise Cache::putImpl(ScriptState* scriptState, Request* request, Response* response)
{
+ KURL url(KURL(), request->url());
+ if (!url.protocolIsInHTTPFamily())
+ return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError("Request scheme '" + url.protocol() + "' is unsupported", scriptState->isolate()));
+ if (request->method() != "GET")
+ return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError("Request method '" + request->method() + "' is unsupported", scriptState->isolate()));
+
WebVector<WebServiceWorkerCache::BatchOperation> batchOperations(size_t(1));
batchOperations[0].operationType = WebServiceWorkerCache::OperationTypePut;
request->populateWebServiceWorkerRequest(batchOperations[0].request);
« no previous file with comments | « LayoutTests/http/tests/serviceworker/cache-put-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698