0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-01-03 05:11:52 +00:00

changed chmod behaviour in Serializer

This commit is contained in:
Nick del Pozo 2016-07-27 12:56:03 +09:00
parent d0c392f77d
commit 8be8cee9b3
2 changed files with 7 additions and 15 deletions

View File

@ -198,10 +198,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends HTMLPurifier_DefinitionCac
if ($result !== false) {
// set permissions of the new file (no execute)
$chmod = $config->get('Cache.SerializerPermissions');
if ($chmod === null) {
// don't do anything
} else {
$chmod = $chmod & 0666;
if ($chmod !== null) {
chmod($file, $chmod);
}
}
@ -229,14 +226,6 @@ class HTMLPurifier_DefinitionCache_Serializer extends HTMLPurifier_DefinitionCac
} elseif (!$this->_testPermissions($base, $chmod)) {
return false;
}
if ($chmod === null) {
trigger_error(
'Base directory ' . $base . ' does not exist,
please create or change using %Cache.SerializerPath',
E_USER_WARNING
);
return false;
}
if ($chmod !== null) {
mkdir($directory, $chmod);
} else {

View File

@ -23,6 +23,7 @@ class HTMLPurifier_DefinitionCache_SerializerTest extends HTMLPurifier_Definitio
$rel_file = HTMLPURIFIER_PREFIX . '/HTMLPurifier/DefinitionCache/Serializer/Test/' .
$config_md5 . '.ser'
);
if($file && file_exists($file)) unlink($file); // prevent previous failures from causing problems
$this->assertIdentical($config_md5, $cache->generateKey($config));
@ -215,10 +216,12 @@ class HTMLPurifier_DefinitionCache_SerializerTest extends HTMLPurifier_Definitio
$def_original = $this->generateDefinition();
$cache->add($def_original, $config);
$this->assertFileExist($dir . '/Test/1.0.0,serial,1.ser');
$this->assertEqual(0600, 0777 & fileperms($dir . '/Test/1.0.0,serial,1.ser'));
$this->assertEqual(0700, 0777 & fileperms($dir . '/Test'));
$file_path = $dir . '/Test/1.0.0,serial,1.ser';
$this->assertFileExist($file_path);
$file_permissions = substr(sprintf("%o",fileperms($file_path)),-4);;
$this->assertEqual("0700", $file_permissions);
unlink($dir . '/Test/1.0.0,serial,1.ser');
rmdir( $dir . '/Test');