Bug 413915 - isValidFeed modifies its first paramter, r=sayrer

This commit is contained in:
Neil Rashbrook 2008-09-06 19:28:36 -07:00
Родитель 9c0b1d8599
Коммит acd9205717
3 изменённых файлов: 12 добавлений и 18 удалений

Просмотреть файл

@ -2825,9 +2825,8 @@ const DOMLinkHandler = {
if (!rels.feed && rels.alternate && rels.stylesheet)
break;
var feed = { title: link.title, href: link.href, type: link.type };
if (isValidFeed(feed, link.ownerDocument.nodePrincipal, rels.feed)) {
FeedHandler.addFeed(feed, link.ownerDocument);
if (isValidFeed(link, link.ownerDocument.nodePrincipal, rels.feed)) {
FeedHandler.addFeed(link, link.ownerDocument);
feedAdded = true;
}
}

Просмотреть файл

@ -62,9 +62,9 @@ function initFeedTab()
}
if (rels.feed || (link.type && rels.alternate && !rels.stylesheet)) {
var feed = { title: link.title, href: link.href, type: link.type || "" };
if (isValidFeed(feed, gDocument.nodePrincipal, rels.feed)) {
var type = feedTypes[feed.type] || feedTypes["application/rss+xml"];
var type = isValidFeed(link, gDocument.nodePrincipal, rels.feed);
if (type) {
type = feedTypes[type] || feedTypes["application/rss+xml"];
addRow(feed.title, type, feed.href);
}
}

Просмотреть файл

@ -631,7 +631,7 @@ function openNewWindowWith(aURL, aDocument, aPostData, aAllowThirdPartyFixup,
/**
* isValidFeed: checks whether the given data represents a valid feed.
*
* @param aData
* @param aLink
* An object representing a feed with title, href and type.
* @param aPrincipal
* The principal of the document, used for security check.
@ -639,33 +639,28 @@ function openNewWindowWith(aURL, aDocument, aPostData, aAllowThirdPartyFixup,
* Whether this is already a known feed or not, if true only a security
* check will be performed.
*/
function isValidFeed(aData, aPrincipal, aIsFeed)
function isValidFeed(aLink, aPrincipal, aIsFeed)
{
if (!aData || !aPrincipal)
if (!aLink || !aPrincipal)
return false;
var type = aLink.type.toLowerCase().replace(/^\s+|\s*(?:;.*)?$/g, "");
if (!aIsFeed) {
var type = aData.type && aData.type.toLowerCase();
type = type.replace(/^\s+|\s*(?:;.*)?$/g, "");
aIsFeed = (type == "application/rss+xml" ||
type == "application/atom+xml");
}
if (aIsFeed) {
try {
urlSecurityCheck(aData.href, aPrincipal,
urlSecurityCheck(aLink.href, aPrincipal,
Components.interfaces.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
return type || "application/rss+xml";
}
catch(ex) {
aIsFeed = false;
}
}
if (type)
aData.type = type;
return aIsFeed;
return null;
}
// aCalledFromModal is optional