mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-28 19:38:13 +00:00
Bug 924568 - Validate hosted app URL before adding. r=ochameau
This commit is contained in:
parent
9cab056f2c
commit
867e5c7b4d
@ -40,7 +40,14 @@ const IDB = {
|
||||
objectStore.openCursor().onsuccess = function(event) {
|
||||
let cursor = event.target.result;
|
||||
if (cursor) {
|
||||
projects.push(cursor.value);
|
||||
if (cursor.value.location) {
|
||||
// We need to make sure this object has a `.location` property.
|
||||
// The UI depends on this property.
|
||||
// This should not be needed as we make sure to register valid
|
||||
// projects, but in the past (before bug 924568), we might have
|
||||
// registered invalid objects.
|
||||
projects.push(cursor.value);
|
||||
}
|
||||
cursor.continue();
|
||||
} else {
|
||||
deferred.resolve(projects);
|
||||
@ -54,16 +61,21 @@ const IDB = {
|
||||
add: function(project) {
|
||||
let deferred = promise.defer();
|
||||
|
||||
var transaction = IDB._db.transaction(["projects"], "readwrite");
|
||||
var objectStore = transaction.objectStore("projects");
|
||||
var request = objectStore.add(project);
|
||||
request.onerror = function(event) {
|
||||
deferred.reject("Unable to add project to the AppProjects indexedDB: " +
|
||||
this.error.name + " - " + this.error.message );
|
||||
};
|
||||
request.onsuccess = function() {
|
||||
deferred.resolve();
|
||||
};
|
||||
if (!project.location) {
|
||||
// We need to make sure this object has a `.location` property.
|
||||
deferred.reject("Missing location property on project object.");
|
||||
} else {
|
||||
let transaction = IDB._db.transaction(["projects"], "readwrite");
|
||||
let objectStore = transaction.objectStore("projects");
|
||||
let request = objectStore.add(project);
|
||||
request.onerror = function(event) {
|
||||
deferred.reject("Unable to add project to the AppProjects indexedDB: " +
|
||||
this.error.name + " - " + this.error.message );
|
||||
};
|
||||
request.onsuccess = function() {
|
||||
deferred.resolve();
|
||||
};
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
},
|
||||
|
@ -82,6 +82,10 @@ let UI = {
|
||||
},
|
||||
|
||||
addHosted: function() {
|
||||
let form = document.querySelector("#new-hosted-project-wrapper")
|
||||
if (!form.checkValidity())
|
||||
return;
|
||||
|
||||
let urlInput = document.querySelector("#url-input");
|
||||
let manifestURL = urlInput.value;
|
||||
AppProjects.addHosted(manifestURL)
|
||||
|
@ -25,7 +25,7 @@
|
||||
<div id="new-packaged-project" onclick="UI.addPackaged()" title="&projects.addPackagedTooltip;">&projects.addPackaged;</div>
|
||||
<div id="new-hosted-project">&projects.addHosted;
|
||||
<form onsubmit="UI.addHosted(); return false;" id="new-hosted-project-wrapper">
|
||||
<input value="" id="url-input" type="url" pattern="https?://.+" placeholder="&projects.hostedManifestPlaceHolder2;" size="50" />
|
||||
<input value="" id="url-input" type="url" required="true" pattern="https?://.+" placeholder="&projects.hostedManifestPlaceHolder2;" size="50" />
|
||||
<div onclick="UI.addHosted()" id="new-hosted-project-click" title="&projects.addHostedTooltip;"></div>
|
||||
<input type="submit" hidden="true"></input>
|
||||
</form>
|
||||
|
Loading…
Reference in New Issue
Block a user