summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authoramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-04 19:30:31 +0000
committeramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-04 19:30:31 +0000
commitb0d9bfae8b254a3c4bff72fbba934271e2191dde (patch)
treed6ea0cd46e2e866f37f6c261ffd938b03421f2f1 /chrome_frame
parent00509dbbd9762b409c94f07860bd20dad7063fa0 (diff)
downloadchromium_src-b0d9bfae8b254a3c4bff72fbba934271e2191dde.zip
chromium_src-b0d9bfae8b254a3c4bff72fbba934271e2191dde.tar.gz
chromium_src-b0d9bfae8b254a3c4bff72fbba934271e2191dde.tar.bz2
Have a consistent UA string with chromeframe token
When using 'PostPlatform' registry, chromeframe UA token appears in the middle whereas when we dynamically append the UA we place it at the end. This has caused issues with sites looking for it in a specific place. This change modifies the logic while dynamically appending the UA to insert it consistently in the place where PostPlatform puts it. BUG=70024 TEST=covered by HtmlUtilUnittest.AddChromeFrameToUserAgentValue Review URL: http://codereview.chromium.org/6246088 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73830 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/html_utils.cc12
-rw-r--r--chrome_frame/test/html_util_unittests.cc36
2 files changed, 30 insertions, 18 deletions
diff --git a/chrome_frame/html_utils.cc b/chrome_frame/html_utils.cc
index 1d4d629..25e4829 100644
--- a/chrome_frame/html_utils.cc
+++ b/chrome_frame/html_utils.cc
@@ -354,8 +354,16 @@ std::string AddChromeFrameToUserAgentValue(const std::string& value) {
}
std::string ret(value);
- ret += " ";
- ret += GetChromeFrameUserAgent();
+ std::string::size_type insert_position = ret.find(')');
+ if (insert_position != std::string::npos) {
+ if (insert_position > 1 && isalnum(ret[insert_position - 1]))
+ ret.insert(insert_position++, ";");
+ ret.insert(insert_position++, " ");
+ ret.insert(insert_position, GetChromeFrameUserAgent());
+ } else {
+ ret += " ";
+ ret += GetChromeFrameUserAgent();
+ }
return ret;
}
diff --git a/chrome_frame/test/html_util_unittests.cc b/chrome_frame/test/html_util_unittests.cc
index b182519..21052cd 100644
--- a/chrome_frame/test/html_util_unittests.cc
+++ b/chrome_frame/test/html_util_unittests.cc
@@ -328,33 +328,37 @@ TEST_F(HtmlUtilUnittest, AddChromeFrameToUserAgentValue) {
"", ""
}, {
"Mozilla/4.7 [en] (WinNT; U)",
- "Mozilla/4.7 [en] (WinNT; U) chromeframe/0.0.0.0"
+ "Mozilla/4.7 [en] (WinNT; U; chromeframe/0.0.0.0)"
}, {
"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT)",
- "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT) chromeframe/0.0.0.0"
+ "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT; chromeframe/0.0.0.0)"
}, {
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; T312461; "
- ".NET CLR 1.1.4322)",
+ ".NET CLR 1.1.4322)",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; T312461; "
- ".NET CLR 1.1.4322) chromeframe/0.0.0.0"
+ ".NET CLR 1.1.4322; chromeframe/0.0.0.0)"
}, {
"Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 4.0) Opera 5.11 [en]",
- "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 4.0) "
- "Opera 5.11 [en] chromeframe/0.0.0.0"
+ "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 4.0; chromeframe/0.0.0.0) "
+ "Opera 5.11 [en]"
+ }, {
+ "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
+ "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; "
+ "chromeframe/0.0.0.0)"
}, {
"Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) "
"Gecko/20030208 Netscape/7.02",
- "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) "
- "Gecko/20030208 Netscape/7.02 chromeframe/0.0.0.0"
+ "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2; "
+ "chromeframe/0.0.0.0) Gecko/20030208 Netscape/7.02"
}, {
"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040612 "
"Firefox/0.8",
- "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040612 "
- "Firefox/0.8 chromeframe/0.0.0.0"
+ "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6; chromeframe/0.0.0.0) "
+ "Gecko/20040612 Firefox/0.8"
}, {
"Mozilla/5.0 (compatible; Konqueror/3.2; Linux) (KHTML, like Gecko)",
- "Mozilla/5.0 (compatible; Konqueror/3.2; Linux) "
- "(KHTML, like Gecko) chromeframe/0.0.0.0"
+ "Mozilla/5.0 (compatible; Konqueror/3.2; Linux; chromeframe/0.0.0.0) "
+ "(KHTML, like Gecko)"
}, {
"Lynx/2.8.4rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.6h",
"Lynx/2.8.4rel.1 libwww-FM/2.14 SSL-MM/1.4.1 "
@@ -362,17 +366,17 @@ TEST_F(HtmlUtilUnittest, AddChromeFrameToUserAgentValue) {
}, {
"Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.7.10) "
"Gecko/20050716 Firefox/1.0.6",
- "Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.7.10) "
- "Gecko/20050716 Firefox/1.0.6 chromeframe/0.0.0.0"
+ "Mozilla/5.0 (X11; U; Linux i686 (x86_64; chromeframe/0.0.0.0); en-US; "
+ "rv:1.7.10) Gecko/20050716 Firefox/1.0.6"
}, {
"Invalid/1.1 ((((((",
"Invalid/1.1 (((((( chromeframe/0.0.0.0",
}, {
"Invalid/1.1 ()))))",
- "Invalid/1.1 ())))) chromeframe/0.0.0.0",
+ "Invalid/1.1 ( chromeframe/0.0.0.0)))))",
}, {
"Strange/1.1 ()",
- "Strange/1.1 () chromeframe/0.0.0.0",
+ "Strange/1.1 ( chromeframe/0.0.0.0)",
}
};