mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-08 14:58:42 +00:00
Properly handle context variables that are NULL.
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
parent
f17490f009
commit
82bcc62058
@ -23,7 +23,7 @@ class HTMLPurifier_Context
|
||||
*/
|
||||
public function register($name, &$ref)
|
||||
{
|
||||
if (isset($this->_storage[$name])) {
|
||||
if (array_key_exists($name, $this->_storage)) {
|
||||
trigger_error(
|
||||
"Name $name produces collision, cannot re-register",
|
||||
E_USER_ERROR
|
||||
@ -41,7 +41,7 @@ class HTMLPurifier_Context
|
||||
*/
|
||||
public function &get($name, $ignore_error = false)
|
||||
{
|
||||
if (!isset($this->_storage[$name])) {
|
||||
if (!array_key_exists($name, $this->_storage)) {
|
||||
if (!$ignore_error) {
|
||||
trigger_error(
|
||||
"Attempted to retrieve non-existent variable $name",
|
||||
@ -60,7 +60,7 @@ class HTMLPurifier_Context
|
||||
*/
|
||||
public function destroy($name)
|
||||
{
|
||||
if (!isset($this->_storage[$name])) {
|
||||
if (!array_key_exists($name, $this->_storage)) {
|
||||
trigger_error(
|
||||
"Attempted to destroy non-existent variable $name",
|
||||
E_USER_ERROR
|
||||
@ -77,7 +77,7 @@ class HTMLPurifier_Context
|
||||
*/
|
||||
public function exists($name)
|
||||
{
|
||||
return isset($this->_storage[$name]);
|
||||
return array_key_exists($name, $this->_storage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,6 +80,14 @@ class HTMLPurifier_ContextTest extends HTMLPurifier_Harness
|
||||
|
||||
}
|
||||
|
||||
public function testNull() {
|
||||
$context = new HTMLPurifier_Context();
|
||||
$var = NULL;
|
||||
$context->register('var', $var);
|
||||
$this->assertNull($context->get('var'));
|
||||
$context->destroy('var');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
||||
|
Loading…
Reference in New Issue
Block a user