Skip to content
Merged
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
2 changes: 1 addition & 1 deletion apps/sharebymail/lib/ShareByMailProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ protected function sendNote(IShare $share): void {
$emailTemplate->setSubject($this->l->t('%s added a note to a file shared with you', [$initiatorDisplayName]));
$emailTemplate->addHeader();
$emailTemplate->addBodySender($initiatorDisplayName, $this->settingsManager->replyToInitiator() ? ($initiatorEmailAddress ?? '') : '');
$emailTemplate->addHeading(htmlspecialchars($heading), $heading);
$emailTemplate->addHeading($heading, $heading);
$emailTemplate->addBodyNote($note, $this->l->t('Note'));

$link = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare',
Expand Down
35 changes: 35 additions & 0 deletions apps/sharebymail/tests/ShareByMailProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2004,4 +2004,39 @@ public function testSendNote(bool $replyToInitiator, string $senderSubline): voi

self::invokePrivate($provider, 'sendNote', [$share]);
}

public function testSendNoteDoesNotEscapeHeading(): void {
$provider = $this->getInstance();
$initiatorUser = $this->createMock(IUser::class);
$initiatorUser->method('getDisplayName')->willReturn('Tom & Jerry\'s');
$initiatorUser->method('getEMailAddress')->willReturn(null);
$this->userManager->method('get')->with('InitiatorUser')->willReturn($initiatorUser);
$this->settingsManager->method('replyToInitiator')->willReturn(false);
$this->defaults->method('getName')->willReturn('UnitTestCloud');
$this->urlGenerator->method('linkToRouteAbsolute')->willReturn('https://example.com/file.txt');

$message = $this->createMock(Message::class);
$this->mailer->method('createMessage')->willReturn($message);
$template = $this->createMock(IEMailTemplate::class);
$this->mailer->method('createEMailTemplate')->willReturn($template);
$template
->expects($this->once())
->method('addHeading')
->with(
'Tom & Jerry\'s shared file.txt with you',
'Tom & Jerry\'s shared file.txt with you'
);
$this->mailer->expects($this->once())->method('send')->with($message);

$node = $this->createMock(File::class);
$node->method('getName')->willReturn('file.txt');
$share = $this->createMock(IShare::class);
$share->method('getSharedBy')->willReturn('InitiatorUser');
$share->method('getSharedWith')->willReturn('john@doe.com');
$share->method('getNode')->willReturn($node);
$share->method('getNote')->willReturn('Some note');
$share->method('getToken')->willReturn('token');

self::invokePrivate($provider, 'sendNote', [$share]);
}
}
Loading