Skip to content

Commit

Permalink
Show the correct error message when a data uri is given that isn't an…
Browse files Browse the repository at this point in the history
… image type.
  • Loading branch information
sizzlemctwizzle committed Oct 17, 2010
1 parent 0c8e663 commit 8343707
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions content/config.js
Expand Up @@ -182,6 +182,8 @@ Config.prototype = {
} catch (e) {
if (updateScript) {
script._dependFail = true;
} else if (script.icon.dataUriError) {
throw new Error(e.message);
} else {
throw new Error('Failed to get @icon '+ value);
}
Expand Down
2 changes: 1 addition & 1 deletion content/scriptdownloader.js
Expand Up @@ -194,7 +194,7 @@ function(dep, file, channel) {
}

// if the dependency type is icon, then check its mime type
if (dep.type == "icon" && !this.script.icon.isImage(channel.contentType)) {
if (dep.type == "icon" && !dep.isImage(channel.contentType)) {
this.errorInstallDependency(this.script, dep,
"Error! @icon is not a image MIME type");
}
Expand Down
4 changes: 4 additions & 0 deletions content/scripticon.js
Expand Up @@ -2,6 +2,7 @@ function ScriptIcon(script) {
ScriptResource.call(this, script);
this.type = "icon";
this._dataURI = null;
this.dataUriError = false;
}

// Inherit from ScriptResource
Expand All @@ -12,6 +13,9 @@ ScriptIcon.prototype.__defineSetter__("metaVal", function(value) {
// accept data uri schemes for image mime types
if (/^data:image\//i.test(value)) {
this._dataURI = value;
} else if (/^data:/i.test(value)) {
this.dataUriError = true;
throw new Error('@icon data: uri must be an image type');
} else {
var resUri = GM_uriFromUrl(this._script._downloadURL);
this._downloadURL = GM_uriFromUrl(value, resUri).spec;
Expand Down

0 comments on commit 8343707

Please sign in to comment.