From 1b8c8865b2a743607a324048e571d40a3539af14 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sun, 7 Jun 2009 16:04:07 -0400 Subject: [PATCH] Fix PHP 5.3.0 problem with numeric indices causing -0 problem. Signed-off-by: Edward Z. Yang --- library/HTMLPurifier/AttrDef/HTML/Class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/library/HTMLPurifier/AttrDef/HTML/Class.php b/library/HTMLPurifier/AttrDef/HTML/Class.php index c925cd39..370068d9 100644 --- a/library/HTMLPurifier/AttrDef/HTML/Class.php +++ b/library/HTMLPurifier/AttrDef/HTML/Class.php @@ -21,11 +21,14 @@ class HTMLPurifier_AttrDef_HTML_Class extends HTMLPurifier_AttrDef_HTML_Nmtokens foreach ($tokens as $token) { if ( ($allowed === null || isset($allowed[$token])) && - !isset($forbidden[$token]) + !isset($forbidden[$token]) && + // We need this O(n) check because of PHP's array + // implementation that casts -0 to 0. + !in_array($token, $ret, true) ) { - $ret[$token] = true; + $ret[] = $token; } } - return array_keys($ret); + return $ret; } }