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

Unified Diff: extensions/common/url_pattern_set.cc

Issue 1658913002: Make extensions use a correct same-origin check. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments. Created 4 years, 11 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
Index: extensions/common/url_pattern_set.cc
diff --git a/extensions/common/url_pattern_set.cc b/extensions/common/url_pattern_set.cc
index 52db387453023762e2f8c66f0926e62eaa2cb7d5..5f09564f9f41bdf703746c041bef028a69ebd20f 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())));
Devlin 2016/02/03 21:01:25 Can we not use the static IsSameOriginWith() here?
palmer 2016/02/03 21:03:08 No, I actually want to maintain the check on GURL:
Devlin 2016/02/03 21:10:11 I'm sure that's right. Can you tell me why? :) (F
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("/*");

Powered by Google App Engine
This is Rietveld 408576698