Bug 1329401 - Rollup updates for FeedConverter.js sync with Firefox as at 20161231 r=IanN a=IanN

(Port Bug 1277685, Bug 1277698, Bug 1165272 Part 2, and Bug 1233899)

[sg bugs]
Bug 1277685 - Nested feed: URIs should only allow http/https as inner URIs
Bug 1277698 - Consider making feed: DANGEROUS_TO_LOAD
[normal bugs]
Bug 1233899 - fix the feeds converter to use default user context origin attributes
Bug 1165272 - Part 2: Replace getNoAppCodebasePrincipal with createCodebasePrincipal.
[minor tweaks]
Bug 1314918 - Fix most of the remaining no-unused-vars issues.
Bug 1199239, remove cpow usage from bookmark this page.
This commit is contained in:
Philip Chee 2017-01-22 23:47:01 +08:00
Родитель 9be3f37efb
Коммит 05a8e17196
1 изменённых файлов: 20 добавлений и 9 удалений

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

@ -254,8 +254,10 @@ FeedConverter.prototype = {
// Now load the actual XUL document.
var chromeURI = Services.io.newURI(FEEDHANDLER_URI);
chromeChannel = Services.io.newChannelFromURIWithLoadInfo(chromeURI, loadInfo);
// carry the origin attributes from the channel that loaded the feed.
chromeChannel.owner = Services.scriptSecurityManager
.getNoAppCodebasePrincipal(chromeURI);
.createCodebasePrincipal(chromeURI,
loadInfo.originAttributes);
chromeChannel.originalURI = result.uri;
}
else
@ -296,7 +298,8 @@ FeedConverter.prototype = {
request.cancel(Components.results.NS_BINDING_ABORTED);
return;
}
var noSniff = httpChannel.getResponseHeader("X-Moz-Is-Feed");
// Note: this throws if the header is not set.
httpChannel.getResponseHeader("X-Moz-Is-Feed");
}
catch (ex) {
this._sniffed = true;
@ -399,7 +402,8 @@ FeedResultService.prototype = {
// fall through
case "bookmarks":
var topWindow = Services.wm.getMostRecentWindow("navigator:browser");
topWindow.PlacesCommandHook.addLiveBookmark(spec, title, subtitle);
topWindow.PlacesCommandHook.addLiveBookmark(spec, title, subtitle)
.catch(Components.utils.reportError);
break;
case "messenger":
Components.classes["@mozilla.org/newsblog-feed-downloader;1"]
@ -477,7 +481,15 @@ function GenericProtocolHandler(scheme, classID) {
GenericProtocolHandler.prototype = {
get protocolFlags() {
var httpPref = "browser.feeds.feeds_like_http"
if (Services.prefs.getPrefType(httpPref) == Services.prefs.PREF_BOOL &&
Services.prefs.getBoolPref(httpPref)) {
return this._http.protocolFlags;
}
return this._http.URI_DANGEROUS_TO_LOAD |
this._http.ALLOWS_PROXY |
this._http.ALLOWS_PROXY_HTTP;
},
get defaultPort() {
@ -500,13 +512,12 @@ GenericProtocolHandler.prototype = {
var prefix = /^feed:\/\//.test(spec) ? "http:" : "";
var inner = Services.io.newURI(spec.replace("feed:", prefix),
originalCharset, baseURI);
var netutil = Components.classes["@mozilla.org/network/util;1"]
.getService(Components.interfaces.nsINetUtil);
if (netutil.URIChainHasFlags(inner,
Components.interfaces.nsIProtocolHandler.URI_INHERITS_SECURITY_CONTEXT))
if (! /^https?/.test(inner.scheme))
throw Components.results.NS_ERROR_MALFORMED_URI;
var uri = netutil.newSimpleNestedURI(inner);
var uri = Services.io.QueryInterface(Components.interfaces.nsINetUtil)
.newSimpleNestedURI(inner);
uri.spec = inner.spec.replace(prefix, "feed:");
return uri;
},