diff --git a/chrome/content/zotero/bindings/attachmentbox.xml b/chrome/content/zotero/bindings/attachmentbox.xml index 0630c6fd8e..2c75f6affc 100644 --- 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,