From 8f5c4d061e4621fca5c2c1c39def35a1993571d4 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Tue, 13 Sep 2022 16:30:01 -0700 Subject: [PATCH] UTF-8 path support (fix #31) --- lib/Exif.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/Exif.php b/lib/Exif.php index 2c6e397c..f93ac2af 100644 --- a/lib/Exif.php +++ b/lib/Exif.php @@ -73,23 +73,22 @@ class Exif { * Sanitize a path to keep only ASCII characters and special characters. * @param string $path */ - public static function sanitizePath(string &$path) { - $path = preg_replace('/[^a-zA-Z0-9\/\.\-\_]/', '', $path); - return $path; + public static function sanitizePath(string $path) { + return mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $path); } /** * Keep only one slash if multiple repeating */ public static function removeExtraSlash(string $path) { - return preg_replace('~/+~', '/', $path); + return mb_ereg_replace('~/+~', '/', $path); } /** * Remove any leading slash present on the path */ public static function removeLeadingSlash(string $path) { - return preg_replace('~^/+~', '', $path); + return mb_ereg_replace('~^/+~', '', $path); } /**