Skip to content

Commit

Permalink
Merge pull request #31053 from owncloud/email-filter-filename
Browse files Browse the repository at this point in the history
Filter file name when sending internal mail
  • Loading branch information
DeepDiver1975 authored Apr 9, 2018
2 parents d190242 + 893f104 commit c7c8b5e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion lib/private/Share/MailNotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use OCP\ILogger;
use OCP\Defaults;
use OCP\Util;
use OC\Share\Filters\MailNotificationFilter;

/**
* Class MailNotifications
Expand Down Expand Up @@ -122,7 +123,6 @@ public function sendInternalShareMail($recipientList, $itemSource, $itemType) {

$items = $this->getItemSharedWithUser($itemSource, $itemType, $recipient);
$filename = trim($items[0]['file_target'], '/');
$subject = (string) $this->l->t('%s shared »%s« with you', [$this->senderDisplayName, $filename]);
$expiration = null;
if (isset($items[0]['expiration'])) {
try {
Expand All @@ -138,6 +138,15 @@ public function sendInternalShareMail($recipientList, $itemSource, $itemType) {
['fileId' => $items[0]['item_source']]
);

$filter = new MailNotificationFilter([
'link' => $link,
'file' => $filename,
]);

$filename = $filter->getFile();
$link = $filter->getLink();

$subject = (string) $this->l->t('%s shared »%s« with you', [$this->senderDisplayName, $filename]);
list($htmlBody, $textBody) = $this->createMailBody($filename, $link, $expiration, null, 'internal');

// send it out now
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/Share/MailNotificationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function testSendLinkShareMailException() {
}

public function testSendInternalShareMail() {
$this->setupMailerMock('TestUser shared »welcome.txt« with you', ['[email protected]' => 'Recipient'], false);
$this->setupMailerMock('TestUser shared »<welcome>.txt« with you', ['[email protected]' => 'Recipient'], false);

/** @var MailNotifications | \PHPUnit_Framework_MockObject_MockObject $mailNotifications */
$mailNotifications = $this->getMockBuilder('OC\Share\MailNotifications')
Expand All @@ -278,7 +278,7 @@ public function testSendInternalShareMail() {
$mailNotifications->method('getItemSharedWithUser')
->withAnyParameters()
->willReturn([
['file_target' => '/welcome.txt', 'item_source' => 123],
['file_target' => '/<welcome>.txt', 'item_source' => 123],
]);

$recipient = $this->getMockBuilder('\OCP\IUser')
Expand Down

0 comments on commit c7c8b5e

Please sign in to comment.