Commit d66e22f2 authored by Marijn Kruisselbrink's avatar Marijn Kruisselbrink Committed by Commit Bot

[FileAPI] Ignore URL fragment when looking up origin of blob: URLs.

Bug: 807436
Change-Id: Ic908a9764c1f9432ee14783561f720597c2c2b42
Reviewed-on: https://chromium-review.googlesource.com/996453Reviewed-by: default avatarDaniel Murphy <dmurph@chromium.org>
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548488}
parent 35c7be21
......@@ -6,7 +6,7 @@ PASS Origin of Blob URL matches our origin
PASS Blob URL parses correctly
PASS Origin of Blob URL matches our origin for Files
PASS Blob URLs can be used in XHR
FAIL XHR with a fragment should succeed promise_test: Unhandled rejection with value: "Got unexpected error event"
PASS XHR with a fragment should succeed
PASS XHR of a revoked URL should fail
PASS Only exact matches should revoke URLs, using XHR
PASS Appending a query string should cause XHR to fail
......@@ -20,7 +20,7 @@ PASS XHR with method "CUSTOM" should fail
PASS XHR should return Content-Type from Blob
FAIL Revoke blob URL after open(), will fetch assert_unreached: Got unexpected error event Reached unreachable code
PASS Blob URLs can be used in fetch
FAIL fetch with a fragment should succeed promise_test: Unhandled rejection with value: object "TypeError: Failed to fetch"
PASS fetch with a fragment should succeed
PASS fetch of a revoked URL should fail
PASS Only exact matches should revoke URLs, using fetch
PASS Appending a query string should cause fetch to fail
......
......@@ -72,6 +72,7 @@ static void SaveToOriginMap(SecurityOrigin* origin, const KURL& url) {
// that the origin can be retrieved when doing security origin check.
//
// See the definition of the origin of a Blob URL in the File API spec.
DCHECK(!url.HasFragmentIdentifier());
if (origin && BlobURL::GetOrigin(url) == "null")
OriginMap()->insert(url.GetString(), origin);
}
......@@ -86,8 +87,11 @@ BlobOriginMap::BlobOriginMap() {
}
SecurityOrigin* BlobOriginMap::GetOrigin(const KURL& url) {
if (url.ProtocolIs("blob"))
return OriginMap()->at(url.GetString());
if (url.ProtocolIs("blob")) {
KURL url_without_fragment = url;
url_without_fragment.RemoveFragmentIdentifier();
return OriginMap()->at(url_without_fragment.GetString());
}
return nullptr;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment