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

Issue 2635023003: Fix a bug in origin header generation for CORS preflight in extensions (Closed)

Created:
3 years, 11 months ago by tyoshino (SeeGerritForStatus)
Modified:
3 years, 11 months ago
Reviewers:
yhirano
CC:
chromium-reviews, tyoshino+watch_chromium.org, loading-reviews_chromium.org, gavinp+loader_chromium.org, blink-reviews, loading-reviews+fetch_chromium.org, Nate Chapin
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Fix a bug in origin header generation for CORS preflight in extensions In the refactoring CL https://codereview.chromium.org/2420603003 by me, I forgot to set the origin header to the preflight request in DocumentThreadableLoader::makeCrossOriginAccessRequest(). When the loading happens in an isolated world, the origin header will have an incorrect value due to this bug. We should add the referrer header to a preflight to conform to the spec, but to limit the effect of this patch, it's not included. See the added TODO. This fix also cleans up the code around the main fix: - createAccessControlPreflightRequests()'s SecurityOrigin argument is unused. Remove it. - makeCrossOriginAccessRequest() has duplicated call to setHTTPOrigin() and setHTTPReferrer() (included in prepareCrossoriginRequest() call next to them). Remove them. - prepareCrossOriginRequest(crossOriginRequest) in the code path for issuing a preflight is meaningless. It should have made on m_actualRequest. That said, since loadActualRequest() has prepareCrossOriginRequest() call, we don't even have to call prepareCrossoriginRequest(m_actualRequest). The only difference https://codereview.chromium.org/2420603003 introduced is that m_actualRequest doesn't have the origin and referrer header until loadActualRequest() is called. The only concern with this change is the preflightResult->allowsCrossOriginHeaders() call in DocumentThreadableLoader::handlePreflightResponse(). However, since these headers are listed in the forbidden header names, presence of these headers doesn't affect the return value of allowsCrossOriginHeaders(). So, just remove the meaningless code. BUG=680320 R=yhirano@chromium.org Review-Url: https://codereview.chromium.org/2635023003 Cr-Commit-Position: refs/heads/master@{#444328} Committed: https://chromium.googlesource.com/chromium/src/+/78d4c0d304e60af63f0a087b8b3de73c27d489b4

Patch Set 1 #

Patch Set 2 : Fixed #

Patch Set 3 : Add tests #

Patch Set 4 : a #

Patch Set 5 : a #

Total comments: 4

Patch Set 6 : Addressed #16 #

Patch Set 7 : Rebase #

Patch Set 8 : Rebase #

Messages

Total messages: 29 (22 generated)
tyoshino (SeeGerritForStatus)
3 years, 11 months ago (2017-01-17 09:04:10 UTC) #11
yhirano
lgtm https://codereview.chromium.org/2635023003/diff/80001/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/access-control-origin-header-in-isolated-world.html File third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/access-control-origin-header-in-isolated-world.html (right): https://codereview.chromium.org/2635023003/diff/80001/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/access-control-origin-header-in-isolated-world.html#newcode13 third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/access-control-origin-header-in-isolated-world.html:13: xhr.open("GET", "http://localhost:8000/xmlhttprequest/resources/access-control-origin-header-in-isolated-world.php"); Please use double-quotation and quotation consistently. ...
3 years, 11 months ago (2017-01-18 05:28:03 UTC) #16
tyoshino (SeeGerritForStatus)
https://codereview.chromium.org/2635023003/diff/80001/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/access-control-origin-header-in-isolated-world.html File third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/access-control-origin-header-in-isolated-world.html (right): https://codereview.chromium.org/2635023003/diff/80001/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/access-control-origin-header-in-isolated-world.html#newcode13 third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/access-control-origin-header-in-isolated-world.html:13: xhr.open("GET", "http://localhost:8000/xmlhttprequest/resources/access-control-origin-header-in-isolated-world.php"); On 2017/01/18 05:28:03, yhirano wrote: > Please ...
3 years, 11 months ago (2017-01-18 06:53:42 UTC) #17
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2635023003/110001
3 years, 11 months ago (2017-01-18 06:56:52 UTC) #21
commit-bot: I haz the power
Failed to apply patch for third_party/WebKit/Source/core/fetch/CrossOriginAccessControlTest.cpp: While running git apply --index -p1; error: patch failed: ...
3 years, 11 months ago (2017-01-18 08:56:42 UTC) #23
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2635023003/130001
3 years, 11 months ago (2017-01-18 09:08:02 UTC) #26
commit-bot: I haz the power
3 years, 11 months ago (2017-01-18 10:39:32 UTC) #29
Message was sent while issue was closed.
Committed patchset #8 (id:130001) as
https://chromium.googlesource.com/chromium/src/+/78d4c0d304e60af63f0a087b8b3d...

Powered by Google App Engine
This is Rietveld 408576698