Commit 31c1959a authored by finnur@chromium.org's avatar finnur@chromium.org

The RSS subscribe.js should not double-decoded the URL passed in.

This causes feeds from Twitter searches to break because the hash
sign (%23) gets decoded before passed to Twitter.

BUG=70226
TEST=ExtensionBrowserTest.ParseFeedInvalidFeed4

Review URL: http://codereview.chromium.org/6332008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72122 0039d316-1c4b-4281-b951-d872f2087c98
parent 40710787
...@@ -50,6 +50,10 @@ const std::string kInvalidFeed1 = "files/feeds/feed_invalid1.xml"; ...@@ -50,6 +50,10 @@ const std::string kInvalidFeed1 = "files/feeds/feed_invalid1.xml";
const std::string kInvalidFeed2 = "files/feeds/feed_invalid2.xml"; const std::string kInvalidFeed2 = "files/feeds/feed_invalid2.xml";
const std::string kLocalization = const std::string kLocalization =
"files/extensions/browsertest/title_localized_pa/simple.html"; "files/extensions/browsertest/title_localized_pa/simple.html";
// We need a triple encoded string to prove that we are not decoding twice in
// subscribe.js because one layer is also stripped off when subscribe.js passes
// it to the XMLHttpRequest object.
const std::string kFeedTripleEncoded = "files/feeds/url%25255Fdecoding.html";
const std::string kHashPageA = const std::string kHashPageA =
"files/extensions/api_test/page_action/hash_change/test_page_A.html"; "files/extensions/api_test/page_action/hash_change/test_page_A.html";
const std::string kHashPageAHash = kHashPageA + "#asdf"; const std::string kHashPageAHash = kHashPageA + "#asdf";
...@@ -622,6 +626,26 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedInvalidFeed3) { ...@@ -622,6 +626,26 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedInvalidFeed3) {
"This feed contains no entries."); "This feed contains no entries.");
} }
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedInvalidFeed4) {
ASSERT_TRUE(test_server()->Start());
ASSERT_TRUE(LoadExtension(
test_data_dir_.AppendASCII("subscribe_page_action")));
// subscribe.js shouldn't double-decode the URL passed in. Otherwise feed
// links such as http://search.twitter.com/search.atom?lang=en&q=%23chrome
// will result in no feed being downloaded because %23 gets decoded to # and
// therefore #chrome is not treated as part of the Twitter query. This test
// uses an underscore instead of a hash, but the principle is the same. If
// we start erroneously double decoding again, the path (and the feed) will
// become valid resulting in a failure for this test.
NavigateToFeedAndValidate(test_server(), kFeedTripleEncoded, browser(), true,
"Feed for Unknown feed name",
"element 'anchor_0' not found",
"element 'desc_0' not found",
"This feed contains no entries.");
}
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeedNoLinks) { IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeedNoLinks) {
ASSERT_TRUE(test_server()->Start()); ASSERT_TRUE(test_server()->Start());
......
...@@ -21,5 +21,5 @@ ...@@ -21,5 +21,5 @@
"popup": "popup.html" "popup": "popup.html"
}, },
"permissions": [ "tabs", "http://*/*", "https://*/*" ], "permissions": [ "tabs", "http://*/*", "https://*/*" ],
"version": "2.1.2" "version": "2.1.3"
} }
...@@ -39,7 +39,7 @@ function navigate() { ...@@ -39,7 +39,7 @@ function navigate() {
var select = document.getElementById('readerDropdown'); var select = document.getElementById('readerDropdown');
var url = var url =
feedReaderList[select.selectedIndex].url.replace( feedReaderList[select.selectedIndex].url.replace(
"%s", escape(encodeURI(feedUrl))); "%s", encodeURIComponent(feedUrl));
// Before we navigate, see if we want to skip this step in the future... // Before we navigate, see if we want to skip this step in the future...
if (storageEnabled) { if (storageEnabled) {
...@@ -105,7 +105,6 @@ function main() { ...@@ -105,7 +105,6 @@ function main() {
"'></" + "script>"; "'></" + "script>";
} }
feedUrl = decodeURIComponent(feedUrl);
req.onload = handleResponse; req.onload = handleResponse;
req.onerror = handleError; req.onerror = handleError;
// Not everyone sets the mime type correctly, which causes handleResponse // Not everyone sets the mime type correctly, which causes handleResponse
......
<rss version="2.0">
<channel>
<title>MyFeedTitle</title>
<item>
<title>Title 1</title>
<link>http://www.google.com</link>
<description>This feed should never been seen by the test because the path
specified doesn't work unless double decoded.</description>
</item>
</channel>
</rss>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment