diff --git a/library/HTMLPurifier/DefinitionCache/Serializer.php b/library/HTMLPurifier/DefinitionCache/Serializer.php index ecacb88f..ce268d91 100644 --- a/library/HTMLPurifier/DefinitionCache/Serializer.php +++ b/library/HTMLPurifier/DefinitionCache/Serializer.php @@ -219,9 +219,15 @@ class HTMLPurifier_DefinitionCache_Serializer extends HTMLPurifier_DefinitionCac } elseif (!$this->_testPermissions($base, $chmod)) { return false; } - $old = umask(0000); mkdir($directory, $chmod); - umask($old); + if (!$this->_testPermissions($directory, $chmod)) { + trigger_error( + 'Base directory ' . $base . ' does not exist, + please create or change using %Cache.SerializerPath', + E_USER_WARNING + ); + return false; + } } elseif (!$this->_testPermissions($directory, $chmod)) { return false; } diff --git a/tests/HTMLPurifier/DefinitionCache/SerializerTest.php b/tests/HTMLPurifier/DefinitionCache/SerializerTest.php index badf9d98..3af8c12f 100644 --- a/tests/HTMLPurifier/DefinitionCache/SerializerTest.php +++ b/tests/HTMLPurifier/DefinitionCache/SerializerTest.php @@ -211,14 +211,14 @@ class HTMLPurifier_DefinitionCache_SerializerTest extends HTMLPurifier_Definitio $config->setReturnValue('get', 1, array('Test.DefinitionRev')); $dir = dirname(__FILE__) . '/SerializerTest'; $config->setReturnValue('get', $dir, array('Cache.SerializerPath')); - $config->setReturnValue('get', 0777, array('Cache.SerializerPermissions')); + $config->setReturnValue('get', 0700, array('Cache.SerializerPermissions')); $def_original = $this->generateDefinition(); $cache->add($def_original, $config); $this->assertFileExist($dir . '/Test/1.0.0,serial,1.ser'); - $this->assertEqual(0666, 0777 & fileperms($dir . '/Test/1.0.0,serial,1.ser')); - $this->assertEqual(0777, 0777 & fileperms($dir . '/Test')); + $this->assertEqual(0600, 0777 & fileperms($dir . '/Test/1.0.0,serial,1.ser')); + $this->assertEqual(0700, 0777 & fileperms($dir . '/Test')); unlink($dir . '/Test/1.0.0,serial,1.ser'); rmdir( $dir . '/Test');