Commit 241356f0 authored by alexpott's avatar alexpott

Issue #1933636 by sun: PhpStorage\FileStorage tries to write a file using the...

Issue #1933636 by sun: PhpStorage\FileStorage tries to write a file using the same name of MTimeProtectedFileStorage's directory name.
parent 8d989472
......@@ -152,6 +152,14 @@ protected function getFullPath($name, &$directory = NULL, &$directory_mtime = NU
* Returns the full path of the containing directory where the file is or should be stored.
*/
protected function getContainingDirectoryFullPath($name) {
// Remove the .php file extension from the directory name.
// Within a single directory, a subdirectory cannot have the same name as a
// file. Thus, when switching between MTimeProtectedFastFileStorage and
// FileStorage, the subdirectory or the file cannot be created in case the
// other file type exists already.
if (substr($name, -4) === '.php') {
$name = substr($name, 0, -4);
}
return $this->directory . '/' . str_replace('/', '#', $name);
}
......
......@@ -66,7 +66,12 @@ public function testSecurity() {
$name = 'simpletest.php';
$php->save($name, '<?php');
$expected_root_directory = sys_get_temp_dir() . '/php/simpletest';
$expected_directory = $expected_root_directory . '/' . $name;
if (substr($name, -4) === '.php') {
$expected_directory = $expected_root_directory . '/' . substr($name, 0, -4);
}
else {
$expected_directory = $expected_root_directory . '/' . $name;
}
$directory_mtime = filemtime($expected_directory);
$expected_filename = $expected_directory . '/' . hash_hmac('sha256', $name, $this->secret . $directory_mtime) . '.php';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment