From d2070fc8b37f956557755077292e0b04b0d00721 Mon Sep 17 00:00:00 2001 From: Yanick Witschi Date: Wed, 1 Dec 2021 16:48:39 +0100 Subject: [PATCH] Fixed aboslute paths not working for file uploads --- library/NotificationCenter/Util/Form.php | 8 ++------ library/NotificationCenter/Util/StringUtil.php | 5 +++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/library/NotificationCenter/Util/Form.php b/library/NotificationCenter/Util/Form.php index caaebacb..4a5b66a7 100644 --- a/library/NotificationCenter/Util/Form.php +++ b/library/NotificationCenter/Util/Form.php @@ -25,12 +25,8 @@ public static function getFileUploadPathForToken(array $file) { // Check if it has been saved by Contao and thus moved to it's final destination already if (isset($file['uploaded']) && $file['uploaded'] === true) { - $basePath = TL_ROOT . '/'; - if (preg_match('/^' . preg_quote($basePath, '/') . '/', $file['tmp_name']) - && file_exists($file['tmp_name']) - ) { - - return str_replace($basePath, '', $file['tmp_name']); + if (file_exists($file['tmp_name'])) { + return $file['tmp_name']; } return null; diff --git a/library/NotificationCenter/Util/StringUtil.php b/library/NotificationCenter/Util/StringUtil.php index 198d92b9..1e64e8f1 100644 --- a/library/NotificationCenter/Util/StringUtil.php +++ b/library/NotificationCenter/Util/StringUtil.php @@ -76,6 +76,11 @@ public static function getTokenAttachments($strAttachmentTokens, array $arrToken $strParsedToken = \Haste\Util\StringUtil::recursiveReplaceTokensAndTags($strToken, $arrTokens, static::NO_TAGS | static::NO_BREAKS); foreach (trimsplit(',', $strParsedToken) as $strFile) { + if (is_file($strFile)) { + $arrAttachments[$strFile] = $strFile; + continue; + } + $strFileFull = TL_ROOT . '/' . $strFile; if (is_file($strFileFull)) {