Browse Source

P4TB-391: Remove path from attachment names.

master
Jörg Knobloch 1 year ago
parent
commit
38a183506a
2 changed files with 29 additions and 4 deletions
  1. +19
    -3
      addon/content/pepmessengercompose.js
  2. +10
    -1
      addon/content/pepmsghdrview.js

+ 19
- 3
addon/content/pepmessengercompose.js View File

@ -344,7 +344,25 @@ var pEpComposer = {
let rowCount = bucket.getRowCount();
let attachmentNames = [];
for (let i = 0; i < rowCount; i++) {
attachmentNames.push(bucket.getItemAtIndex(i).attachment.name);
let name = bucket.getItemAtIndex(i).attachment.name;
// Note that TB will remove a single backslash, but it can be tested with
// a double backslash, for example: C:\\temp\\test.txt.
let slashPos = Math.max(name.lastIndexOf("\\"), name.lastIndexOf("/"));
if (slashPos >= 0) {
name = name.substring(slashPos + 1);
let item = bucket.getItemAtIndex(i);
let originalName = item.attachment.name;
let itemLabel = item.querySelector(".attachmentcell-name");
item.attachment.name = name;
item.setAttribute("name", name);
itemLabel.setAttribute("value", name);
let event = this.win.document.createEvent("CustomEvent");
event.initCustomEvent("attachment-renamed", true, true, originalName);
item.dispatchEvent(event);
}
attachmentNames.push(name);
}
for (let i = 0; i < rowCount; i++) {
for (let j = i + 1; j < rowCount; j++) {
@ -378,8 +396,6 @@ var pEpComposer = {
item.setAttribute("name", newName);
itemLabel.setAttribute("value", newName);
this.win.gContentChanged = true;
let event = this.win.document.createEvent("CustomEvent");
event.initCustomEvent("attachment-renamed", true, true, originalName);
item.dispatchEvent(event);


+ 10
- 1
addon/content/pepmsghdrview.js View File

@ -327,7 +327,16 @@ var pEpHdrView = {
attLength = this.win.currentAttachments.length;
let attachmentNames = [];
for (let i = 0; i < attLength; i++) {
attachmentNames.push(this.win.currentAttachments[i].name);
let name = this.win.currentAttachments[i].name;
// Note that TB will remove a single backslash, but it can be tested with
// a double backslash, for example: C:\\temp\\test.txt.
let slashPos = Math.max(name.lastIndexOf("\\"), name.lastIndexOf("/"));
if (slashPos >= 0) {
name = name.substring(slashPos + 1);
this.win.currentAttachments[i].name = name;
needRefresh = true;
}
attachmentNames.push(name);
}
for (let i = 0; i < attLength; i++) {
for (let j = i + 1; j < attLength; j++) {


Loading…
Cancel
Save