[go: nahoru, domu]

url::DomainIs should not assume lowercase hosts

URLs do not always have lowercase hosts. Namely, escape chars in URL hosts are uppercase:
GURL("https://www.,.com/").host() == "www.%2C.com"

Additionally, this CL has two small optimizations:
1. Null-check the inner URL before checking SchemeIsFilesystem which saves a strlen
2. Remove a call to LowercaseEqualsASCII in favor of just regular comparison, since
   both inputs need to be canonicalized anyway.

Bug: None
Change-Id: I1c275fd0d247d020a021c34ce6af13a7adc45b47
Reviewed-on: https://chromium-review.googlesource.com/634157
Commit-Queue: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: Brett Wilson <brettw@chromium.org>
Reviewed-by: Pavel Kalinnikov <pkalinnikov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#498668}
diff --git a/url/origin.h b/url/origin.h
index c5bdf63..8b59b5a 100644
--- a/url/origin.h
+++ b/url/origin.h
@@ -161,7 +161,7 @@
   GURL GetURL() const;
 
   // Same as GURL::DomainIs. If |this| origin is unique, then returns false.
-  bool DomainIs(base::StringPiece lower_ascii_domain) const;
+  bool DomainIs(base::StringPiece canonical_domain) const;
 
   // Allows Origin to be used as a key in STL (for example, a std::set or
   // std::map).