mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 23:28:42 +00:00
Proposed fix to Serializer code.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
This commit is contained in:
parent
6a221a3045
commit
1ef4375dbb
@ -214,6 +214,11 @@ class HTMLPurifier_DefinitionCache_Serializer extends HTMLPurifier_DefinitionCac
|
|||||||
{
|
{
|
||||||
$directory = $this->generateDirectoryPath($config);
|
$directory = $this->generateDirectoryPath($config);
|
||||||
$chmod = $config->get('Cache.SerializerPermissions');
|
$chmod = $config->get('Cache.SerializerPermissions');
|
||||||
|
if ($chmod === null) {
|
||||||
|
// TODO: This races
|
||||||
|
if (is_dir($directory)) return true;
|
||||||
|
return mkdir($directory);
|
||||||
|
}
|
||||||
if (!is_dir($directory)) {
|
if (!is_dir($directory)) {
|
||||||
$base = $this->generateBaseDirectoryPath($config);
|
$base = $this->generateBaseDirectoryPath($config);
|
||||||
if (!is_dir($base)) {
|
if (!is_dir($base)) {
|
||||||
@ -226,19 +231,16 @@ class HTMLPurifier_DefinitionCache_Serializer extends HTMLPurifier_DefinitionCac
|
|||||||
} elseif (!$this->_testPermissions($base, $chmod)) {
|
} elseif (!$this->_testPermissions($base, $chmod)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($chmod !== null) {
|
if (!mkdir($directory, $chmod)) {
|
||||||
mkdir($directory, $chmod);
|
|
||||||
} else {
|
|
||||||
mkdir($directory);
|
|
||||||
}
|
|
||||||
if (!$this->_testPermissions($directory, $chmod)) {
|
|
||||||
trigger_error(
|
trigger_error(
|
||||||
'Base directory ' . $base . ' does not exist,
|
'Could not create directory ' . $directory . '',
|
||||||
please create or change using %Cache.SerializerPath',
|
|
||||||
E_USER_WARNING
|
E_USER_WARNING
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!$this->_testPermissions($directory, $chmod)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} elseif (!$this->_testPermissions($directory, $chmod)) {
|
} elseif (!$this->_testPermissions($directory, $chmod)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user