diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js index 084c56bf9f..57688d467f 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