Bug 829679 - Package installation without // on the manifest URL causes webapps.json corruption r=ferjm

This commit is contained in:
Fabrice Desré 2013-01-14 11:40:46 -08:00
Родитель b6458db871
Коммит 3b272eba76
1 изменённых файлов: 22 добавлений и 13 удалений

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

@ -72,14 +72,23 @@ WebappsRegistry.prototype = {
return uri.prePath;
},
_validateScheme: function(aURL) {
let scheme = Services.io.newURI(aURL, null, null).scheme;
if (scheme != "http" && scheme != "https") {
_validateURL: function(aURL) {
let uri;
try {
uri = Services.io.newURI(aURL, null, null);
let scheme = uri.scheme;
if (!uri.schemeIs("http") && !uri.schemeIs("https")) {
throw new Components.Exception(
"INVALID_URL_SCHEME: '" + scheme + "'; must be 'http' or 'https'",
Cr.NS_ERROR_FAILURE
);
}
} catch(e) {
throw new Components.Exception(
"INVALID_URL_SCHEME: '" + scheme + "'; must be 'http' or 'https'",
Cr.NS_ERROR_FAILURE
"INVALID_URL: '" + aURL, Cr.NS_ERROR_FAILURE
);
}
return uri.spec;
},
// Checks that we run as a foreground page, and fire an error on the
@ -105,14 +114,14 @@ WebappsRegistry.prototype = {
// mozIDOMApplicationRegistry implementation
install: function(aURL, aParams) {
let uri = this._validateURL(aURL);
let request = this.createRequest();
if (!this._ensureForeground(request)) {
return request;
}
this._validateScheme(aURL);
let installURL = this._window.location.href;
let requestID = this.getRequestId(request);
let receipts = (aParams && aParams.receipts &&
@ -126,8 +135,8 @@ WebappsRegistry.prototype = {
cpmm.sendAsyncMessage("Webapps:Install",
{ app: {
installOrigin: this._getOrigin(installURL),
origin: this._getOrigin(aURL),
manifestURL: aURL,
origin: this._getOrigin(uri),
manifestURL: uri,
receipts: receipts,
categories: categories
},
@ -184,14 +193,14 @@ WebappsRegistry.prototype = {
// mozIDOMApplicationRegistry2 implementation
installPackage: function(aURL, aParams) {
let uri = this._validateURL(aURL);
let request = this.createRequest();
if (!this._ensureForeground(request)) {
return request;
}
this._validateScheme(aURL);
let installURL = this._window.location.href;
let requestID = this.getRequestId(request);
let receipts = (aParams && aParams.receipts &&
@ -205,8 +214,8 @@ WebappsRegistry.prototype = {
cpmm.sendAsyncMessage("Webapps:InstallPackage",
{ app: {
installOrigin: this._getOrigin(installURL),
origin: this._getOrigin(aURL),
manifestURL: aURL,
origin: this._getOrigin(uri),
manifestURL: uri,
receipts: receipts,
categories: categories
},