Skip to content

Commit

Permalink
Merge pull request #10433 from nextcloud/fix/mailto/bcc-recipients
Browse files Browse the repository at this point in the history
fix(mailto): Handle BCC recipients only
  • Loading branch information
GretaD authored Dec 2, 2024
2 parents fe181e3 + 970c3ac commit 77ecbeb
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 @@ -411,7 +411,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 @@ -362,6 +362,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 @@ -40,6 +40,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 @@ -380,6 +381,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 77ecbeb

Please sign in to comment.