diff options
author | erikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-26 20:29:12 +0000 |
---|---|---|
committer | erikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-26 20:29:12 +0000 |
commit | 8e698b6c58faf3a267ebc7512e530dc4323a010b (patch) | |
tree | a9e1d055c274fb2f6fdda77d5a5cfe3d7f2a3b15 /chrome_frame/utils.cc | |
parent | eba0116741b4849809fc57d97cdf527a1b5da507 (diff) | |
download | chromium_src-8e698b6c58faf3a267ebc7512e530dc4323a010b.zip chromium_src-8e698b6c58faf3a267ebc7512e530dc4323a010b.tar.gz chromium_src-8e698b6c58faf3a267ebc7512e530dc4323a010b.tar.bz2 |
Modify the parsing of X-UA-COMPATIBLE header (and meta tag) to allow comma or semi-colon as delimiter for backwards compatibility.
BUG=52601
TEST=chrome_frame_unittests / UtilTests.XUaCompatibleDirectiveTest
Review URL: http://codereview.chromium.org/4103004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63937 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/utils.cc')
-rw-r--r-- | chrome_frame/utils.cc | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc index 2e5f13e..eff1331 100644 --- a/chrome_frame/utils.cc +++ b/chrome_frame/utils.cc @@ -1533,11 +1533,13 @@ void WaitWithMessageLoop(HANDLE* handles, int count, DWORD timeout) { } } -bool CheckXUaCompatibleDirective(const std::string& directive, - int ie_major_version) { +// Returns -1 if no directive is found, std::numeric_limits<int>::max() if the +// directive matches all IE versions ('Chrome=1') or the maximum IE version +// matched ('Chrome=IE7' => 7) +int GetXUaCompatibleDirective(const std::string& directive, char delimiter) { net::HttpUtil::NameValuePairsIterator name_value_pairs(directive.begin(), directive.end(), - ';'); + delimiter); // Loop through the values until a valid 'Chrome=<FILTER>' entry is found while (name_value_pairs.GetNext()) { @@ -1552,7 +1554,7 @@ bool CheckXUaCompatibleDirective(const std::string& directive, size_t filter_length = filter_end - filter_begin; if (filter_length == 1 && *filter_begin == '1') { - return true; + return std::numeric_limits<int>::max(); } if (filter_length < 3 || @@ -1568,9 +1570,18 @@ bool CheckXUaCompatibleDirective(const std::string& directive, } // The first valid directive we find wins, whether it matches or not - return ie_major_version <= header_ie_version; + return header_ie_version; } - return false; + return -1; +} + +bool CheckXUaCompatibleDirective(const std::string& directive, + int ie_major_version) { + int header_ie_version = GetXUaCompatibleDirective(directive, ';'); + if (header_ie_version == -1) { + header_ie_version = GetXUaCompatibleDirective(directive, ','); + } + return header_ie_version >= ie_major_version; } void EnumerateKeyValues(HKEY parent_key, const wchar_t* sub_key_name, |