#2003: Don't close img and br tags on HTMLText.Summary

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@47836 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-01-10 03:58:14 +00:00
parent ef682e54c8
commit af8d7a1802

View File

@ -55,14 +55,18 @@ class HTMLText extends Text {
$summary .= $parts[$pIndex++] . ' '; $summary .= $parts[$pIndex++] . ' ';
} }
// Tags that shouldn't be closed
$noClose = array("br", "img");
// make sure that the summary is well formed XHTML by closing tags // make sure that the summary is well formed XHTML by closing tags
while( $openTag = array_pop( $tagStack ) ) { while( $openTag = array_pop( $tagStack ) ) {
preg_match( '/^<(\w+)\s+/', $openTag, $tagName ); preg_match( '/^<(\w+)\s+/', $openTag, $tagName );
if(sizeof($tagName) > 0) if(sizeof($tagName) > 0) {
if(!in_array($tagName[1], $noClose)) {
$summary .= "</{$tagName[1]}>"; $summary .= "</{$tagName[1]}>";
} }
}
}
return $summary; return $summary;
} }