Bug 494328 - Media file display names should use decodeURIComponent instead of decodeURI. r=sayrer

This commit is contained in:
Geoff Lankow 2010-07-24 11:06:10 +02:00
parent cd44d4ece9
commit 1438d6450f
4 changed files with 66 additions and 2 deletions

View File

@ -554,9 +554,9 @@ FeedWriter.prototype = {
var url = makeURI(aURL);
url.QueryInterface(Ci.nsIURL);
if (url == null || url.fileName.length == 0)
return aURL;
return decodeURIComponent(aURL);
return decodeURI(url.fileName);
return decodeURIComponent(url.fileName);
},
/**

View File

@ -55,6 +55,8 @@ _TEST_FILES = test_bug408328.html \
bug408328-data.xml \
test_bug368464.html \
bug368464-data.xml \
test_bug494328.html \
bug494328-data.xml \
test_registerHandler.html \
$(NULL)

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>Channel title</title>
<description>Channel description</description>
<link>Channel link</link>
<item>
<title>Episode 1</title>
<enclosure url="http://www.example.com/podcasts/Episode%201" length="0" type="audio/x-m4a" />
</item>
<item>
<title>Episode 2</title>
<enclosure url="http://www.example.com/podcasts/Episode%20%232" length="0" type="audio/x-m4a" />
</item>
<item>
<title>Episode 3</title>
<enclosure url="http://www.example.com/podcasts/Episode%20%233/" length="0" type="audio/x-m4a" />
</item>
<item>
<title>Episode 4</title>
<enclosure url="http://www.example.com/podcasts/Is%20This%20Episode%20%234%3F" length="0" type="audio/x-m4a" />
</item>
</channel>
</rss>

View File

@ -0,0 +1,38 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=494328
-->
<head>
<title>Test for bug 494328</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=494328">Mozilla Bug 494328</a>
<p id="display"><iframe id="testFrame" src="bug494328-data.xml"></iframe></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 494328 **/
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
var links = $("testFrame").contentDocument.getElementById("feedContent").querySelectorAll("div.enclosure > a");
is(links[0].textContent, "Episode 1", "filename decoded incorrectly");
is(links[1].textContent, "Episode #2", "filename decoded incorrectly");
is(links[2].textContent, "http://www.example.com/podcasts/Episode #3/", "filename decoded incorrectly");
is(links[3].textContent, "Is This Episode #4?", "filename decoded incorrectly");
});
addLoadEvent(SimpleTest.finish);
</script>
</pre>
</body>
</html>