From 6de42d8d1dd1d4cf93893ac5789cc7c045d94a6d Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Fri, 1 Sep 2006 16:17:56 +0000 Subject: [PATCH] Attempt to fix strange foreach troubles. git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@364 48356398-32a2-884e-a903-53898d9a118a --- library/HTMLPurifier/Lexer/DOMLex.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/library/HTMLPurifier/Lexer/DOMLex.php b/library/HTMLPurifier/Lexer/DOMLex.php index 1ba9675f..2df01f52 100644 --- a/library/HTMLPurifier/Lexer/DOMLex.php +++ b/library/HTMLPurifier/Lexer/DOMLex.php @@ -87,19 +87,20 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer return; } + $attr = $node->hasAttributes() ? + $this->transformAttrToAssoc($node->attributes) : + array(); + // We still have to make sure that the element actually IS empty if (!$node->childNodes->length) { if ($collect) { - $tokens[] = $this->factory->createEmpty( - $node->tagName, - $this->transformAttrToAssoc($node->attributes) - ); + $tokens[] = $this->factory->createEmpty($node->tagName, $attr); } } else { if ($collect) { // don't wrap on first iteration $tokens[] = $this->factory->createStart( $tag_name = $node->tagName, // somehow, it get's dropped - $this->transformAttrToAssoc($node->attributes) + $attr ); } foreach ($node->childNodes as $node) {