Skip to content

Commit

Permalink
fix(mailto): Handle BCC recipients only
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst authored and backportbot[bot] committed Dec 2, 2024
1 parent ff49911 commit c8bfa04
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/components/MailboxThread.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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(''),
},
Expand Down
12 changes: 12 additions & 0 deletions tests/Unit/Controller/PageControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -381,6 +382,17 @@ public function testComposeWithCc() {
$this->assertEquals($expected, $response);
}

public function testComposeBcc() {
$bcc = '[email protected]';
$uri = "mailto:?bcc=$bcc";

$expected = new RedirectResponse('?bcc=' . urlencode($bcc));

$response = $this->controller->compose($uri);

$this->assertEquals($expected, $response);
}

public function testComposeWithBcc() {
$address = '[email protected]';
$bcc = '[email protected]';
Expand Down

0 comments on commit c8bfa04

Please sign in to comment.