1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 this.EXPORTED_SYMBOLS = [ "Feeds" ];
9 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
11 XPCOMUtils.defineLazyModuleGetter(this, "BrowserUtils",
12 "resource://gre/modules/BrowserUtils.jsm");
14 const Ci = Components.interfaces;
19 * isValidFeed: checks whether the given data represents a valid feed.
22 * An object representing a feed with title, href and type.
24 * The principal of the document, used for security check.
26 * Whether this is already a known feed or not, if true only a security
27 * check will be performed.
29 isValidFeed: function(aLink, aPrincipal, aIsFeed) {
30 if (!aLink || !aPrincipal)
33 var type = aLink.type.toLowerCase().replace(/^\s+|\s*(?:;.*)?$/g, "");
35 aIsFeed = (type == "application/rss+xml" ||
36 type == "application/atom+xml");
41 BrowserUtils.urlSecurityCheck(aLink.href, aPrincipal,
42 Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
43 return type || "application/rss+xml";