| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (C) 2009 Google Inc. All rights reserved. | 2  * Copyright (C) 2009 Google Inc. All rights reserved. | 
| 3  * | 3  * | 
| 4  * Redistribution and use in source and binary forms, with or without | 4  * Redistribution and use in source and binary forms, with or without | 
| 5  * modification, are permitted provided that the following conditions are | 5  * modification, are permitted provided that the following conditions are | 
| 6  * met: | 6  * met: | 
| 7  * | 7  * | 
| 8  *     * Redistributions of source code must retain the above copyright | 8  *     * Redistributions of source code must retain the above copyright | 
| 9  * notice, this list of conditions and the following disclaimer. | 9  * notice, this list of conditions and the following disclaimer. | 
| 10  *     * Redistributions in binary form must reproduce the above | 10  *     * Redistributions in binary form must reproduce the above | 
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 91   if (!m_hostIsIPAddress) { | 91   if (!m_hostIsIPAddress) { | 
| 92     WebPublicSuffixList* suffixList = Platform::current()->publicSuffixList(); | 92     WebPublicSuffixList* suffixList = Platform::current()->publicSuffixList(); | 
| 93     if (!suffixList) | 93     if (!suffixList) | 
| 94       return; | 94       return; | 
| 95 | 95 | 
| 96     size_t publicSuffixLength = suffixList->getPublicSuffixLength(m_host); | 96     size_t publicSuffixLength = suffixList->getPublicSuffixLength(m_host); | 
| 97     if (m_host.length() <= publicSuffixLength + 1) { | 97     if (m_host.length() <= publicSuffixLength + 1) { | 
| 98       m_hostIsPublicSuffix = true; | 98       m_hostIsPublicSuffix = true; | 
| 99     } else if (subdomainSetting == AllowRegisterableDomains && | 99     } else if (subdomainSetting == AllowRegisterableDomains && | 
| 100                publicSuffixLength) { | 100                publicSuffixLength) { | 
| 101       // The "2" in the next line is 1 for the '.', plus a 1-char minimum label 
     length. | 101       // The "2" in the next line is 1 for the '.', plus a 1-char minimum label | 
|  | 102       // length. | 
| 102       const size_t dot = | 103       const size_t dot = | 
| 103           m_host.reverseFind('.', m_host.length() - publicSuffixLength - 2); | 104           m_host.reverseFind('.', m_host.length() - publicSuffixLength - 2); | 
| 104       if (dot == kNotFound) | 105       if (dot == kNotFound) | 
| 105         m_registerableDomain = host; | 106         m_registerableDomain = host; | 
| 106       else | 107       else | 
| 107         m_registerableDomain = host.substring(dot + 1); | 108         m_registerableDomain = host.substring(dot + 1); | 
| 108     } | 109     } | 
| 109   } | 110   } | 
| 110 } | 111 } | 
| 111 | 112 | 
| 112 OriginAccessEntry::MatchResult OriginAccessEntry::matchesOrigin( | 113 OriginAccessEntry::MatchResult OriginAccessEntry::matchesOrigin( | 
| 113     const SecurityOrigin& origin) const { | 114     const SecurityOrigin& origin) const { | 
| 114   ASSERT(origin.protocol() == origin.protocol().lower()); | 115   ASSERT(origin.protocol() == origin.protocol().lower()); | 
| 115 | 116 | 
| 116   if (m_protocol != origin.protocol()) | 117   if (m_protocol != origin.protocol()) | 
| 117     return DoesNotMatchOrigin; | 118     return DoesNotMatchOrigin; | 
| 118 | 119 | 
| 119   return matchesDomain(origin); | 120   return matchesDomain(origin); | 
| 120 } | 121 } | 
| 121 | 122 | 
| 122 OriginAccessEntry::MatchResult OriginAccessEntry::matchesDomain( | 123 OriginAccessEntry::MatchResult OriginAccessEntry::matchesDomain( | 
| 123     const SecurityOrigin& origin) const { | 124     const SecurityOrigin& origin) const { | 
| 124   ASSERT(origin.host() == origin.host().lower()); | 125   ASSERT(origin.host() == origin.host().lower()); | 
| 125   // Special case: Include subdomains and empty host means "all hosts, including
      ip addresses". | 126   // Special case: Include subdomains and empty host means "all hosts, including | 
|  | 127   // ip addresses". | 
| 126   if (m_subdomainSettings != DisallowSubdomains && m_host.isEmpty()) | 128   if (m_subdomainSettings != DisallowSubdomains && m_host.isEmpty()) | 
| 127     return MatchesOrigin; | 129     return MatchesOrigin; | 
| 128 | 130 | 
| 129   // Exact match. | 131   // Exact match. | 
| 130   if (m_host == origin.host()) | 132   if (m_host == origin.host()) | 
| 131     return MatchesOrigin; | 133     return MatchesOrigin; | 
| 132 | 134 | 
| 133   // Don't try to do subdomain matching on IP addresses. | 135   // Don't try to do subdomain matching on IP addresses. | 
| 134   if (m_hostIsIPAddress) | 136   if (m_hostIsIPAddress) | 
| 135     return DoesNotMatchOrigin; | 137     return DoesNotMatchOrigin; | 
| 136 | 138 | 
| 137   // Match subdomains. | 139   // Match subdomains. | 
| 138   switch (m_subdomainSettings) { | 140   switch (m_subdomainSettings) { | 
| 139     case DisallowSubdomains: | 141     case DisallowSubdomains: | 
| 140       return DoesNotMatchOrigin; | 142       return DoesNotMatchOrigin; | 
| 141 | 143 | 
| 142     case AllowSubdomains: | 144     case AllowSubdomains: | 
| 143       if (!IsSubdomainOfHost(origin.host(), m_host)) | 145       if (!IsSubdomainOfHost(origin.host(), m_host)) | 
| 144         return DoesNotMatchOrigin; | 146         return DoesNotMatchOrigin; | 
| 145       break; | 147       break; | 
| 146 | 148 | 
| 147     case AllowRegisterableDomains: | 149     case AllowRegisterableDomains: | 
| 148       // Fall back to a simple subdomain check if no registerable domain could b
     e found: | 150       // Fall back to a simple subdomain check if no registerable domain could | 
|  | 151       // be found: | 
| 149       if (m_registerableDomain.isEmpty()) { | 152       if (m_registerableDomain.isEmpty()) { | 
| 150         if (!IsSubdomainOfHost(origin.host(), m_host)) | 153         if (!IsSubdomainOfHost(origin.host(), m_host)) | 
| 151           return DoesNotMatchOrigin; | 154           return DoesNotMatchOrigin; | 
| 152       } else if (m_registerableDomain != origin.host() && | 155       } else if (m_registerableDomain != origin.host() && | 
| 153                  !IsSubdomainOfHost(origin.host(), m_registerableDomain)) { | 156                  !IsSubdomainOfHost(origin.host(), m_registerableDomain)) { | 
| 154         return DoesNotMatchOrigin; | 157         return DoesNotMatchOrigin; | 
| 155       } | 158       } | 
| 156       break; | 159       break; | 
| 157   }; | 160   }; | 
| 158 | 161 | 
| 159   if (m_hostIsPublicSuffix) | 162   if (m_hostIsPublicSuffix) | 
| 160     return MatchesOriginButIsPublicSuffix; | 163     return MatchesOriginButIsPublicSuffix; | 
| 161 | 164 | 
| 162   return MatchesOrigin; | 165   return MatchesOrigin; | 
| 163 } | 166 } | 
| 164 | 167 | 
| 165 }  // namespace blink | 168 }  // namespace blink | 
| OLD | NEW | 
|---|