Closed Bug 1804796 Opened 2 years ago Closed 2 years ago

Running compose.getComposeDetails() followed by compose.setComposeDetails() in a WebExtension deletes the quoted reply in plainText mode.

Categories

(Thunderbird :: Add-Ons: Extensions API, defect)

Thunderbird 102
defect

Tracking

(thunderbird_esr102+ fixed, thunderbird109 fixed)

RESOLVED FIXED
110 Branch
Tracking Status
thunderbird_esr102 + fixed
thunderbird109 --- fixed

People

(Reporter: nelia.collins, Assigned: TbSync)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files)

Attached file compose-bug-0.1.xpi

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0

Steps to reproduce:

User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.5.1

I have a webextension that adds a header and footer to outgoing messages. Starting with Thunderbird 102, when using this extension, it adds the header and footer but deletes the quoted reply in plaintext messages.

I attached an extension that reproduces the issue I'm seeing with my actual extension. The essential part is that it has a line

let details = await browser.compose.getComposeDetails(tabId);

followed by

await browser.compose.setComposeDetails(tabId, { plainTextBody: details.plainTextBody });

Steps to reproduce the problem:

  1. Install an addon that updates the message body as above using an onBeforeSend listener. (Example attached.)

  2. Reply to an existing message using plaintext format. (If your default is to send html messages, hold down the Shift key while clicking the Reply button to begin composing a plaintext message.)

  3. Compose your message and click Send.

Actual results:

The quoted reply in the message (all lines following the line "On 12/8/22 15:05, XX YY wrote:" and beginning with the character ">") vanishes.

Expected results:

The message text should have been unchanged.

For what it's worth: if I update the attachment so that it inserts a space before the ">" on the lines of the reply, then those lines do not vanish.

See Also: → 1674830

This is very unexpected. I know I fixed this in Bug 1674830 (as in "I have seen it working"), but moz-regression clearly shows that it is not working at all since that patch landed.

Ah, it is not working in the onBeforeSend event, but does work as expected elsewhere. For example, in an onClicked event:

browser.composeAction.onClicked.addListener(async (tab) => {
   let details = await browser.compose.getComposeDetails(tab.id);
   details.plainTextBody = "Pre Text\n\n" + details.plainTextBody + "\n\nPost Text";
   await browser.compose.setComposeDetails(tab.id, details);
   console.log(details);
});

Thanks for your report, I will investigate why this is happening.

Assignee: nobody → john
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Target Milestone: --- → 110 Branch

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/d91f2c174081
Remove read-only flag from editor before using InsertTextWithQuotations(). r=aleca

Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED

Comment on attachment 9308666 [details]
Bug 1804796 - Remove read-only flag from editor before using InsertTextWithQuotations(). r=#thunderbird-reviewers

[Approval Request Comment]
Regression caused by (bug #):
1674830

User impact if declined:
Quoted text is stripped when a message is manipulated by add-ons in the onBeforeSend event (no way for the user to prevent sending the stripped message).

Testing completed (on c-c, etc.):
Just landed on Daily.

Risk to taking this patch (and alternatives if risky):
Very low. We simply toggle the read-only flag of the editor before and after manipulating the editor. I would like to get this on ESR as fast as possible.

Attachment #9308666 - Flags: approval-comm-beta?

Comment on attachment 9308666 [details]
Bug 1804796 - Remove read-only flag from editor before using InsertTextWithQuotations(). r=#thunderbird-reviewers

[Triage Comment]
Approved for beta

Attachment #9308666 - Flags: approval-comm-beta? → approval-comm-beta+
See Also: → 1812254

Comment on attachment 9308666 [details]
Bug 1804796 - Remove read-only flag from editor before using InsertTextWithQuotations(). r=#thunderbird-reviewers

[Approval Request Comment]
Regression caused by (bug #):
1674830

User impact if declined:
Quoted text is stripped when a message is manipulated by add-ons in the onBeforeSend event (no way for the user to prevent sending the stripped message).

Testing completed (on c-c, etc.):
1 month on Beta.

Risk to taking this patch (and alternatives if risky):
Very low. We simply toggle the read-only flag of the editor before and after manipulating the editor.

Attachment #9308666 - Flags: approval-comm-esr102?

Comment on attachment 9308666 [details]
Bug 1804796 - Remove read-only flag from editor before using InsertTextWithQuotations(). r=#thunderbird-reviewers

[Triage Comment]
approved for esr102

Attachment #9308666 - Flags: approval-comm-esr102? → approval-comm-esr102+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: