Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use unmodified email body for forward/reply #7846

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions lib/Controller/MessagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -506,28 +506,30 @@ public function getHtmlBody(int $id, bool $plain = false): Response {

$client = $this->clientFactory->getClient($account);
try {
$html = $this->mailManager->getImapMessage(
$imapMessage = $this->mailManager->getImapMessage(
$client,
$account,
$mailbox,
$message->getUid(),
true
)->getHtmlBody(
$id
);
} finally {
$client->logout();
}

$htmlResponse = $plain ?
HtmlResponse::plain($html) :
HtmlResponse::withResizer(
$html,
if ($plain) {
$htmlResponse = HtmlResponse::plain(
$imapMessage->getHtmlBody($id, true)
);
} else {
$htmlResponse = HtmlResponse::withResizer(
$imapMessage->getHtmlBody($id),
$this->nonceManager->getNonce(),
$this->urlGenerator->getAbsoluteURL(
$this->urlGenerator->linkTo('mail', 'js/htmlresponse.js')
)
);
}

// Harden the default security policy
$policy = new ContentSecurityPolicy();
Expand Down
9 changes: 7 additions & 2 deletions lib/Model/IMAPMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,11 +540,16 @@ public function jsonSerialize() {
}

/**
* @param int $id
* @param int $id message id
* @param bool $plain false to sanitize the body
*
* @return string
*/
public function getHtmlBody(int $id): string {
public function getHtmlBody(int $id, bool $plain = false): string {
if ($plain === true) {
return $this->htmlMessage;
}

return $this->htmlService->sanitizeHtmlMailBody($this->htmlMessage, [
'id' => $id,
], function ($cid) {
Expand Down