1
0
Fork 0

Handle weird chars in cache keys

pull/808/head
Jordi Boggiano 2012-06-18 15:34:08 +02:00
parent dc2a9bfe62
commit 6d1377838b
1 changed files with 3 additions and 0 deletions

View File

@ -44,6 +44,7 @@ class Cache
public function read($file)
{
$file = preg_replace('{[^a-z0-9.]}i', '-', $file);
if ($this->enabled && file_exists($this->root . $file)) {
return file_get_contents($this->root . $file);
}
@ -52,12 +53,14 @@ class Cache
public function write($file, $contents)
{
if ($this->enabled) {
$file = preg_replace('{[^a-z0-9.]}i', '-', $file);
file_put_contents($this->root . $file, $contents);
}
}
public function sha1($file)
{
$file = preg_replace('{[^a-z0-9.]}i', '-', $file);
if ($this->enabled && file_exists($this->root . $file)) {
return sha1_file($this->root . $file);
}