diff options
author | palmer <palmer@chromium.org> | 2016-02-03 15:21:36 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-03 23:22:25 +0000 |
commit | 5c437bcc7a51edbef45242c5173cf7871fde2866 (patch) | |
tree | cff6102f961c969435e9698cb821715f69ca64b2 /extensions/common | |
parent | a2280cd27bd434f6033d3ab0c70886c06e3882b0 (diff) | |
download | chromium_src-5c437bcc7a51edbef45242c5173cf7871fde2866.zip chromium_src-5c437bcc7a51edbef45242c5173cf7871fde2866.tar.gz chromium_src-5c437bcc7a51edbef45242c5173cf7871fde2866.tar.bz2 |
Make extensions use a correct same-origin check.
GURL::GetOrigin does not do the right thing for all types of URLs.
BUG=573317
Review URL: https://codereview.chromium.org/1658913002
Cr-Commit-Position: refs/heads/master@{#373381}
Diffstat (limited to 'extensions/common')
-rw-r--r-- | extensions/common/url_pattern_set.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/extensions/common/url_pattern_set.cc b/extensions/common/url_pattern_set.cc index 52db387..5f09564 100644 --- a/extensions/common/url_pattern_set.cc +++ b/extensions/common/url_pattern_set.cc @@ -14,6 +14,7 @@ #include "extensions/common/error_utils.h" #include "extensions/common/url_pattern.h" #include "url/gurl.h" +#include "url/origin.h" #include "url/url_constants.h" namespace extensions { @@ -152,11 +153,13 @@ void URLPatternSet::ClearPatterns() { } bool URLPatternSet::AddOrigin(int valid_schemes, const GURL& origin) { - DCHECK_EQ(origin.GetOrigin(), origin); + if (origin.is_empty()) + return false; + const url::Origin real_origin(origin); + DCHECK(real_origin.IsSameOriginWith(url::Origin(origin.GetOrigin()))); URLPattern origin_pattern(valid_schemes); // Origin adding could fail if |origin| does not match |valid_schemes|. - if (origin_pattern.Parse(origin.GetOrigin().spec()) != - URLPattern::PARSE_SUCCESS) { + if (origin_pattern.Parse(origin.spec()) != URLPattern::PARSE_SUCCESS) { return false; } origin_pattern.SetPath("/*"); |