aboutsummaryrefslogtreecommitdiffstats
path: root/apps/sharebymail/lib/ShareByMailProvider.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/sharebymail/lib/ShareByMailProvider.php')
-rw-r--r--apps/sharebymail/lib/ShareByMailProvider.php18
1 files changed, 14 insertions, 4 deletions
diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php
index 62ba9d35f3f..c1438c01125 100644
--- a/apps/sharebymail/lib/ShareByMailProvider.php
+++ b/apps/sharebymail/lib/ShareByMailProvider.php
@@ -334,6 +334,16 @@ class ShareByMailProvider implements IShareProvider {
$share->getNote()
);
+ if (!$this->mailer->validateMailAddress($share->getSharedWith())) {
+ $this->removeShareFromTable($shareId);
+ $e = new HintException('Failed to send share by mail. Got an invalid email address: ' . $share->getSharedWith(),
+ $this->l->t('Failed to send share by email. Got an invalid email address'));
+ $this->logger->error('Failed to send share by mail. Got an invalid email address ' . $share->getSharedWith(), [
+ 'app' => 'sharebymail',
+ 'exception' => $e,
+ ]);
+ }
+
try {
$link = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare',
['token' => $share->getToken()]);
@@ -679,7 +689,7 @@ class ShareByMailProvider implements IShareProvider {
* @param \DateTime|null $expirationTime
* @return int
*/
- protected function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $password, $sendPasswordByTalk, $hideDownload, $label, $expirationTime, $note = '') {
+ protected function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $password, $sendPasswordByTalk, $hideDownload, $label, $expirationTime, $note = ''): int {
$qb = $this->dbConnection->getQueryBuilder();
$qb->insert('share')
->setValue('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))
@@ -774,7 +784,7 @@ class ShareByMailProvider implements IShareProvider {
} catch (\Exception $e) {
}
- $this->removeShareFromTable($share->getId());
+ $this->removeShareFromTable((int)$share->getId());
}
/**
@@ -970,9 +980,9 @@ class ShareByMailProvider implements IShareProvider {
/**
* remove share from table
*
- * @param string $shareId
+ * @param int $shareId
*/
- protected function removeShareFromTable($shareId) {
+ protected function removeShareFromTable(int $shareId): void {
$qb = $this->dbConnection->getQueryBuilder();
$qb->delete('share')
->where($qb->expr()->eq('id', $qb->createNamedParameter($shareId)));