This commit is contained in:
Dennis Eichhorn 2016-10-31 10:14:25 +01:00
parent 8c1e601bfd
commit dd04acdb59
4 changed files with 11 additions and 10 deletions

View File

@ -142,7 +142,7 @@ class FileCache implements CacheInterface
return false;
}
$path = File::sanitize($key);
$path = File::sanitize($key, '~');
file_put_contents($this->cachePath . '/' . $path, $this->build($value, $expire));
@ -158,7 +158,7 @@ class FileCache implements CacheInterface
return false;
}
$path = File::sanitize($key);
$path = File::sanitize($key, '~');
if (!file_exists($this->cachePath . '/' . $path)) {
file_put_contents($this->cachePath . '/' . $path, $this->build($value, $expire));
@ -274,7 +274,7 @@ class FileCache implements CacheInterface
return null;
}
$name = File::sanitize($key);
$name = File::sanitize($key, '~');
$path = $this->cachePath . '/' . $name;
if(!file_exists($path)) {
@ -341,7 +341,7 @@ class FileCache implements CacheInterface
return false;
}
$name = File::sanitize($key);
$name = File::sanitize($key, '~');
$path = $this->cachePath . '/' . $name;
if ($expire < 0 && file_exists($path)) {
@ -404,7 +404,7 @@ class FileCache implements CacheInterface
return false;
}
$path = File::sanitize($key);
$path = File::sanitize($key, '~');
if (file_exists($this->cachePath . '/' . $path)) {
file_put_contents($this->cachePath . '/' . $path, $this->build($value, $expire));

View File

@ -197,13 +197,14 @@ interface ContainerInterface
* Make name/path operating system safe.
*
* @param string $path Path of the resource
* @param string $replace Replace invalid chars with
*
* @return string
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function sanitize(string $path) : string;
public static function sanitize(string $path, string $replace = '') : string;
/**
* Get amount of sub-resources.

View File

@ -260,9 +260,9 @@ class Directory extends FileAbstract implements DirectoryInterface
/**
* {@inheritdoc}
*/
public static function sanitize(string $path) : string
public static function sanitize(string $path, string $replace = '') : string
{
return preg_replace('[^\w\s\d\.\-_~,;:\[\]\(\]\/]', '', $path);
return preg_replace('[^\w\s\d\.\-_~,;:\[\]\(\]\/]', $replace, $path);
}
/**

View File

@ -143,9 +143,9 @@ class File extends FileAbstract implements FileInterface
/**
* {@inheritdoc}
*/
public static function sanitize(string $path) : string
public static function sanitize(string $path, string $replace = '') : string
{
return preg_replace('/[^\w\s\d\.\-_~,;\[\]\(\]]/', '', $path);
return preg_replace('/[^\w\s\d\.\-_~,;\[\]\(\]]/', $replace, $path);
}
/**