mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
#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:
parent
ef682e54c8
commit
af8d7a1802
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user