Skip to content

fix(IMAP): don't add whitespaces to drafts#12196

Open
max65482 wants to merge 1 commit intonextcloud:mainfrom
max65482:fix/whitespaces-in-drafts
Open

fix(IMAP): don't add whitespaces to drafts#12196
max65482 wants to merge 1 commit intonextcloud:mainfrom
max65482:fix/whitespaces-in-drafts

Conversation

@max65482
Copy link
Contributor

Fixes #12190

@max65482
Copy link
Contributor Author

max65482 commented Feb 8, 2026

Could someone review?

@kesselb
Copy link
Contributor

kesselb commented Feb 10, 2026

Thanks for your pr 👍

So, it's not the regex that you mentioned in the issue?

@kesselb kesselb force-pushed the fix/whitespaces-in-drafts branch from 76fb4f9 to 19d46fd Compare February 10, 2026 14:35
@max65482
Copy link
Contributor Author

So, it's not the regex that you mentioned in the issue?

Yes, I was wrong. The regex is innocent.

@max65482 max65482 force-pushed the fix/whitespaces-in-drafts branch from 19d46fd to 90bcbf4 Compare March 2, 2026 09:57
@max65482
Copy link
Contributor Author

max65482 commented Mar 2, 2026

Failed integration tests should be fixed now.

Signed-off-by: Maximilian Martin <maximilian_martin@gmx.de>
@max65482 max65482 force-pushed the fix/whitespaces-in-drafts branch 2 times, most recently from ad2cf9f to 4c97bd8 Compare March 6, 2026 09:37
@kesselb
Copy link
Contributor

kesselb commented Mar 6, 2026

Thanks a lot for your PR 👍

Sorry that the review takes so long 🙈

Your change works.

The commits b6d019b / https://github.com/nextcloud/mail/blame/c55f4d6f633b2865a2ecb16a30abdeddd1d4424c/lib/message.php doesn't give me any hint why the newlines were added. I'd hope @ChristophWurst has an idea?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts how ImapMessageFetcher concatenates MIME part bodies so it only inserts separators between parts (instead of always appending trailing \n\n / <br><br>), and updates the integration tests to match the new plaintext body output.

Changes:

  • Update plain-text body concatenation to avoid unconditional trailing \n\n and stop trimming part contents.
  • Update HTML body concatenation to avoid unconditional trailing <br><br>.
  • Update integration test expectations for getPlainBody() newline behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
lib/IMAP/ImapMessageFetcher.php Changes how plaintext/HTML bodies are appended, inserting separators only when previous content exists.
tests/Integration/IMAP/ImapMessageFetcherIntegrationTest.php Adjusts assertions to match the updated body formatting (no unconditional trailing blank lines).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if ($p[0] === 'message') {
$data = $this->loadBodyData($p, $partNo, $isFetched);
$this->plainMessage .= trim($data) . "\n\n";
if (!empty($this->plainMessage)) {
Comment on lines +428 to +431
if (!empty($this->plainMessage)) {
$this->plainMessage .= "\n\n";
}
$this->plainMessage .= $data;
$this->hasHtmlMessage = true;
$data = $this->loadBodyData($p, $partNo, $isFetched);
$this->htmlMessage .= $data . '<br><br>';
if (!empty($this->htmlMessage)) {
@kesselb
Copy link
Contributor

kesselb commented Mar 16, 2026

@max65482 mind to have a look at copilot's suggestions? Rebase against latest main would also be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Additional newlines/spaces added to drafts

3 participants