UTF-8 path support (fix #31)

pull/37/head
Varun Patil 2022-09-13 16:30:01 -07:00
parent 3ef562efe3
commit 8f5c4d061e
1 changed files with 4 additions and 5 deletions

View File

@ -73,23 +73,22 @@ class Exif {
* Sanitize a path to keep only ASCII characters and special characters. * Sanitize a path to keep only ASCII characters and special characters.
* @param string $path * @param string $path
*/ */
public static function sanitizePath(string &$path) { public static function sanitizePath(string $path) {
$path = preg_replace('/[^a-zA-Z0-9\/\.\-\_]/', '', $path); return mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $path);
return $path;
} }
/** /**
* Keep only one slash if multiple repeating * Keep only one slash if multiple repeating
*/ */
public static function removeExtraSlash(string $path) { public static function removeExtraSlash(string $path) {
return preg_replace('~/+~', '/', $path); return mb_ereg_replace('~/+~', '/', $path);
} }
/** /**
* Remove any leading slash present on the path * Remove any leading slash present on the path
*/ */
public static function removeLeadingSlash(string $path) { public static function removeLeadingSlash(string $path) {
return preg_replace('~^/+~', '', $path); return mb_ereg_replace('~^/+~', '', $path);
} }
/** /**