Browse Source

Handle weird chars in cache keys

Jordi Boggiano 12 years ago
parent
commit
6d1377838b
1 changed files with 3 additions and 0 deletions
  1. 3 0
      src/Composer/Cache.php

+ 3 - 0
src/Composer/Cache.php

@@ -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);
         }