mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-01-03 05:11:52 +00:00
Stop trying to chmod if SerializerPermissions is null, fixes #71
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
This commit is contained in:
parent
ed180f595d
commit
0166c3728b
@ -424,7 +424,7 @@
|
|||||||
<directive id="Cache.SerializerPermissions">
|
<directive id="Cache.SerializerPermissions">
|
||||||
<file name="HTMLPurifier/DefinitionCache/Serializer.php">
|
<file name="HTMLPurifier/DefinitionCache/Serializer.php">
|
||||||
<line>200</line>
|
<line>200</line>
|
||||||
<line>218</line>
|
<line>219</line>
|
||||||
</file>
|
</file>
|
||||||
</directive>
|
</directive>
|
||||||
<directive id="Filter.ExtractStyleBlocks.TidyImpl">
|
<directive id="Filter.ExtractStyleBlocks.TidyImpl">
|
||||||
|
Binary file not shown.
@ -1,5 +1,5 @@
|
|||||||
Cache.SerializerPermissions
|
Cache.SerializerPermissions
|
||||||
TYPE: int
|
TYPE: int/null
|
||||||
VERSION: 4.3.0
|
VERSION: 4.3.0
|
||||||
DEFAULT: 0755
|
DEFAULT: 0755
|
||||||
--DESCRIPTION--
|
--DESCRIPTION--
|
||||||
@ -8,4 +8,9 @@ DEFAULT: 0755
|
|||||||
Directory permissions of the files and directories created inside
|
Directory permissions of the files and directories created inside
|
||||||
the DefinitionCache/Serializer or other custom serializer path.
|
the DefinitionCache/Serializer or other custom serializer path.
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
In HTML Purifier 4.8.0, this also supports <code>NULL</code>,
|
||||||
|
which means that no chmod'ing or directory creation shall
|
||||||
|
occur.
|
||||||
|
</p>
|
||||||
--# vim: et sw=4 sts=4
|
--# vim: et sw=4 sts=4
|
||||||
|
@ -198,12 +198,13 @@ class HTMLPurifier_DefinitionCache_Serializer extends HTMLPurifier_DefinitionCac
|
|||||||
if ($result !== false) {
|
if ($result !== false) {
|
||||||
// set permissions of the new file (no execute)
|
// set permissions of the new file (no execute)
|
||||||
$chmod = $config->get('Cache.SerializerPermissions');
|
$chmod = $config->get('Cache.SerializerPermissions');
|
||||||
if (!$chmod) {
|
if ($chmod === null) {
|
||||||
$chmod = 0644; // invalid config or simpletest
|
// don't do anything
|
||||||
}
|
} else {
|
||||||
$chmod = $chmod & 0666;
|
$chmod = $chmod & 0666;
|
||||||
chmod($file, $chmod);
|
chmod($file, $chmod);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,9 +217,6 @@ 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) {
|
|
||||||
$chmod = 0755; // invalid config or simpletest
|
|
||||||
}
|
|
||||||
if (!is_dir($directory)) {
|
if (!is_dir($directory)) {
|
||||||
$base = $this->generateBaseDirectoryPath($config);
|
$base = $this->generateBaseDirectoryPath($config);
|
||||||
if (!is_dir($base)) {
|
if (!is_dir($base)) {
|
||||||
@ -231,7 +229,19 @@ class HTMLPurifier_DefinitionCache_Serializer extends HTMLPurifier_DefinitionCac
|
|||||||
} elseif (!$this->_testPermissions($base, $chmod)) {
|
} elseif (!$this->_testPermissions($base, $chmod)) {
|
||||||
return false;
|
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);
|
mkdir($directory, $chmod);
|
||||||
|
} else {
|
||||||
|
mkdir($directory);
|
||||||
|
}
|
||||||
if (!$this->_testPermissions($directory, $chmod)) {
|
if (!$this->_testPermissions($directory, $chmod)) {
|
||||||
trigger_error(
|
trigger_error(
|
||||||
'Base directory ' . $base . ' does not exist,
|
'Base directory ' . $base . ' does not exist,
|
||||||
@ -268,7 +278,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends HTMLPurifier_DefinitionCac
|
|||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (function_exists('posix_getuid')) {
|
if (function_exists('posix_getuid') && $chmod !== null) {
|
||||||
// POSIX system, we can give more specific advice
|
// POSIX system, we can give more specific advice
|
||||||
if (fileowner($dir) === posix_getuid()) {
|
if (fileowner($dir) === posix_getuid()) {
|
||||||
// we can chmod it ourselves
|
// we can chmod it ourselves
|
||||||
|
Loading…
Reference in New Issue
Block a user