From 82448c4a4d367e4e17382ae0c458bdaef3e59d45 Mon Sep 17 00:00:00 2001 From: aurimasv Date: Thu, 21 Mar 2013 03:24:47 -0500 Subject: [PATCH] Escape special characters in file paths when attaching files --- chrome/content/zotero/xpcom/file.js | 15 +++++++++++++++ .../zotero/xpcom/translation/translate_item.js | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js index 084c56bf9..57688d467 100644 --- a/chrome/content/zotero/xpcom/file.js +++ b/chrome/content/zotero/xpcom/file.js @@ -43,6 +43,21 @@ Zotero.File = new function(){ this.getCharsetFromFile = getCharsetFromFile; this.addCharsetListener = addCharsetListener; + /** + * Encode special characters in file paths that might cause problems, + * like # (but preserve slashes or colons) + * + * @param {String} path File path + * @return {String} Encoded file path + */ + this.encodeFilePath = function(path) { + var parts = path.split(/([\\\/:]+)/); + // Every other item is the separator + for (var i=0, n=parts.length; i