From c8bfa044316e6345bd2b21050a6447e1302a9796 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 2 Dec 2024 12:12:35 +0100 Subject: [PATCH] fix(mailto): Handle BCC recipients only Signed-off-by: Christoph Wurst --- lib/Controller/PageController.php | 5 ++++- src/components/MailboxThread.vue | 1 + tests/Unit/Controller/PageControllerTest.php | 12 ++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index d27a28df37..980bedb4fe 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -405,7 +405,10 @@ public function filteredDraft(string $filter, int $mailboxId, int $draftId): Tem */ public function compose(string $uri): RedirectResponse { $parts = parse_url($uri); - $params = ['to' => $parts['path']]; + $params = []; + if (isset($parts['path'])) { + $params['to'] = $parts['path']; + } if (isset($parts['query'])) { $parts = explode('&', $parts['query']); foreach ($parts as $part) { diff --git a/src/components/MailboxThread.vue b/src/components/MailboxThread.vue index 70320a75c8..67db056cf3 100644 --- a/src/components/MailboxThread.vue +++ b/src/components/MailboxThread.vue @@ -266,6 +266,7 @@ export default { accountId, to: this.stringToRecipients(this.$route.query.to), cc: this.stringToRecipients(this.$route.query.cc), + bcc: this.stringToRecipients(this.$route.query.bcc), subject: this.$route.query.subject || '', body: this.$route.query.body ? detect(this.$route.query.body) : html(''), }, diff --git a/tests/Unit/Controller/PageControllerTest.php b/tests/Unit/Controller/PageControllerTest.php index 7e28e12376..f7358d7fa6 100644 --- a/tests/Unit/Controller/PageControllerTest.php +++ b/tests/Unit/Controller/PageControllerTest.php @@ -53,6 +53,7 @@ use PHPUnit\Framework\MockObject\MockObject; use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; +use function urlencode; class PageControllerTest extends TestCase { /** @var string */ @@ -381,6 +382,17 @@ public function testComposeWithCc() { $this->assertEquals($expected, $response); } + public function testComposeBcc() { + $bcc = 'blind@example.com'; + $uri = "mailto:?bcc=$bcc"; + + $expected = new RedirectResponse('?bcc=' . urlencode($bcc)); + + $response = $this->controller->compose($uri); + + $this->assertEquals($expected, $response); + } + public function testComposeWithBcc() { $address = 'user@example.com'; $bcc = 'blind@example.com';