commit 59ef7cba047e5f11e0a15ab35ef85a7e495f7619
parent 64fb9efa760d22c83f2875b19a57c6381a3e81a0
Author: Aurimas Vinckevicius <aurimas.dev@gmail.com>
Date: Fri, 22 Nov 2013 17:39:02 -0600
When renaming attachment files, keep file extension if not provided
Diffstat:
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/chrome/content/zotero/bindings/attachmentbox.xml b/chrome/content/zotero/bindings/attachmentbox.xml
@@ -388,15 +388,21 @@
// Rename associated file
if (checkState.value) {
- var renamed = item.renameAttachmentFile(newTitle.value);
+ var newFilename = newTitle.value.trim();
+ if (newFilename.search(/\.\w{1,10}$/) == -1) {
+ // User did not specify extension. Use current
+ var oldExt = item.getFilename().match(/\.\w{1,10}$/);
+ if (oldExt) newFilename += oldExt[0];
+ }
+ var renamed = item.renameAttachmentFile(newFilename);
if (renamed == -1) {
var confirmed = nsIPS.confirm(
window,
'',
- newTitle.value + ' exists. Overwrite existing file?'
+ newFilename + ' exists. Overwrite existing file?'
);
if (confirmed) {
- item.renameAttachmentFile(newTitle.value, true);
+ item.renameAttachmentFile(newFilename, true);
break;
}
// If they said not to overwrite existing file,