commit c70fd9fa397bfe4bf89442d2cfeab276b190f256
parent df6426af2e428784d0fb5600aa4e1b75fa15f6fd
Author: Simon Kornblith <simon@simonster.com>
Date: Fri, 21 Sep 2012 16:51:10 -0700
Merge pull request #166 from aurimasv/attachments
Allow relative file attachment import. Fix some bugs in _parsePath.
Diffstat:
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js
@@ -204,7 +204,7 @@ Zotero.Translate.ItemSaver.prototype = {
},
"_saveAttachmentFile":function(attachment, parentID) {
- const urlRe = /(([A-Za-z]+):\/\/[^\s]*)/i;
+ const urlRe = /(([a-z][-+\.a-z0-9]*):\/\/[^\s]*)/i; //according to RFC3986
Zotero.debug("Translate: Adding attachment", 4);
if(!attachment.url && !attachment.path) {
@@ -215,7 +215,7 @@ Zotero.Translate.ItemSaver.prototype = {
if(!attachment.path) {
// see if this is actually a file URL
var m = urlRe.exec(attachment.url);
- var protocol = m ? m[2].toLowerCase() : "";
+ var protocol = m ? m[2].toLowerCase() : "file";
if(protocol == "file") {
attachment.path = attachment.url;
attachment.url = false;
@@ -275,7 +275,7 @@ Zotero.Translate.ItemSaver.prototype = {
var uri = IOService.newURI(path, "", this._baseURI);
}
catch (e) {
- var msg = "Error parsing attachment path: " + attachment.path;
+ var msg = "Error parsing attachment path: " + path;
Zotero.logError(msg);
Zotero.debug("Translate: " + msg, 2);
return false;
@@ -284,14 +284,14 @@ Zotero.Translate.ItemSaver.prototype = {
try {
var file = uri.QueryInterface(Components.interfaces.nsIFileURL).file;
if (file.path == '/') {
- var msg = "Error parsing attachment path: " + attachment.path;
+ var msg = "Error parsing attachment path: " + path;
Zotero.logError(msg);
Zotero.debug("Translate: " + msg, 2);
return false;
}
}
catch (e) {
- var msg = "Error getting file from attachment path: " + attachment.path;
+ var msg = "Error getting file from attachment path: " + path;
Zotero.logError(msg);
Zotero.debug("Translate: " + msg, 2);
return false;