|
|
@ -308,10 +308,11 @@ var pEpHdrView = { |
|
|
|
}, |
|
|
|
|
|
|
|
// Adapted from Enigmail.
|
|
|
|
hidePgpKeys() { |
|
|
|
hidePgpKeysAndMakeAttachmentNamesUnique() { |
|
|
|
let attachmentList = this.win.document.getElementById("attachmentList"); |
|
|
|
if (!attachmentList) return; |
|
|
|
if (this.win.currentAttachments.length == 0) return; |
|
|
|
let needRefresh = false; |
|
|
|
|
|
|
|
// Remove attachments of type application/pgp-keys.
|
|
|
|
let attLength = this.win.currentAttachments.length; |
|
|
@ -320,7 +321,46 @@ var pEpHdrView = { |
|
|
|
this.win.currentAttachments.splice(i, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
if (attLength == this.win.currentAttachments.length) return; |
|
|
|
if (attLength != this.win.currentAttachments.length) needRefresh = true; |
|
|
|
|
|
|
|
// Make the names unique.
|
|
|
|
attLength = this.win.currentAttachments.length; |
|
|
|
let attachmentNames = []; |
|
|
|
for (let i = 0; i < attLength; i++) { |
|
|
|
attachmentNames.push(this.win.currentAttachments[i].name); |
|
|
|
} |
|
|
|
for (let i = 0; i < attLength; i++) { |
|
|
|
for (let j = i + 1; j < attLength; j++) { |
|
|
|
if (attachmentNames[i] == attachmentNames[j]) { |
|
|
|
let name = attachmentNames[i]; |
|
|
|
let dotPos = name.lastIndexOf("."); |
|
|
|
let tryAppend = 1; |
|
|
|
let newName; |
|
|
|
let found; |
|
|
|
do { |
|
|
|
tryAppend++; |
|
|
|
if (dotPos < 0) { |
|
|
|
newName = `${name}(${tryAppend})`; |
|
|
|
} else { |
|
|
|
newName = `${name.substring(0, dotPos)}(${tryAppend})${name.substring(dotPos)}`; |
|
|
|
} |
|
|
|
found = false; |
|
|
|
for (let k = 0; k < attLength; k++) { |
|
|
|
if (newName == attachmentNames[k]) { |
|
|
|
found = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} while (found); |
|
|
|
|
|
|
|
attachmentNames[j] = newName; |
|
|
|
this.win.currentAttachments[j].name = newName; |
|
|
|
needRefresh = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!needRefresh) return; |
|
|
|
|
|
|
|
// Delete attachment display.
|
|
|
|
while (attachmentList.hasChildNodes()) { |
|
|
@ -355,7 +395,7 @@ var pEpHdrView = { |
|
|
|
return false; |
|
|
|
}; |
|
|
|
|
|
|
|
this.hidePgpKeys(); |
|
|
|
this.hidePgpKeysAndMakeAttachmentNamesUnique(); |
|
|
|
|
|
|
|
// Update the privacy information and subject.
|
|
|
|
// Body and attachments are handled via the PGP MIME Proxy.
|
|
|
|