#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,13 +55,17 @@ class HTMLText extends Text {
$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
while( $openTag = array_pop( $tagStack ) ) {
preg_match( '/^<(\w+)\s+/', $openTag, $tagName );
if(sizeof($tagName) > 0)
$summary .= "</{$tagName[1]}>";
if(sizeof($tagName) > 0) {
if(!in_array($tagName[1], $noClose)) {
$summary .= "</{$tagName[1]}>";
}
}
}
return $summary;