commit 2a292faeafaeacf0c79f95b09c1b2d3396dd6978
parent 7ac35363e35e32adbd42dfa1537ea7956bbe5847
Author: Simon Kornblith <simon@simonster.com>
Date: Wed, 14 May 2014 23:54:45 -0400
Merge pull request #481 from aurimasv/import-network-shares
Recognize Windows network shares on file attachment import
Diffstat:
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js
@@ -329,10 +329,16 @@ Zotero.Translate.ItemSaver.prototype = {
var file;
// First, try to parse as absolute path
- if(((/[a-zA-Z]:\\/.test(path) && Zotero.isWin) || (path[0] === "/" && !Zotero.isWin))
- && (file = this._parseAbsolutePath(path))) {
- Zotero.debug("Translate: Got file "+path+" as absolute path");
- return file;
+ if((/^[a-zA-Z]:[\\\/]|^\\\\/.test(path) && Zotero.isWin) // Paths starting with drive letter or network shares starting with \\
+ || (path[0] === "/" && !Zotero.isWin)) {
+ // Forward slashes on Windows are not allowed in filenames, so we can
+ // assume they're meant to be backslashes. Backslashes are technically
+ // allowed on Linux, so the reverse cannot be done reliably.
+ var nativePath = Zotero.isWin ? path.replace('/', '\\', 'g') : path;
+ if (file = this._parseAbsolutePath(nativePath)) {
+ Zotero.debug("Translate: Got file "+nativePath+" as absolute path");
+ return file;
+ }
}
// Next, try to parse as URI