diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js index 393f7531a..2a3377d32 100644 --- 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;