From c795f13f819372ed595805354e5ce27cd092df93 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 11 Apr 2018 11:22:11 +0200 Subject: [PATCH] remove 4-byte unicode when cleaning subjects --- api/src/Mail.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/api/src/Mail.php b/api/src/Mail.php index c47a882cd0..4183bb636f 100644 --- a/api/src/Mail.php +++ b/api/src/Mail.php @@ -6438,13 +6438,19 @@ class Mail * Under Windows the characters < > ? " : | \ / * are not allowed. * % causes problems with VFS UI * + * 4-byte unicode is also unwanted, as our current MySQL collation can store it + * + * We also dont want empty filenames, using lang('empty') instead. + * * @param string $filename - * @return Cleaned filename, with problematic characters replaced with '_'. + * @return Cleaned filename, with problematic characters replaced with ' '. */ static function clean_subject_for_filename($filename) { - static $filter_pattern = '$[\f\n\t\x0b\:*#?<>%"\|/\\\?]$'; - return preg_replace($filter_pattern, "_", trim($filename)); + static $filter_pattern = '$[\f\n\t\x0b\:*#?<>%"\|/\x{10000}-\x{10FFFF}]$u'; + $file = trim(preg_replace($filter_pattern, ' ', $filename)); + if (empty($file)) $file = lang('empty'); + return $file; } /**