Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix tag order when closing open tags with TextHelper::truncate()

  • Loading branch information...
commit acca796d10255fc7ebbf8a51dcc1f29baf87234b 1 parent 4e7e06f
@shama shama authored
View
2  lib/Cake/Test/Case/View/Helper/TextHelperTest.php
@@ -129,7 +129,7 @@ public function testTruncate() {
Steve Jobs escrita por Walter Isaacson "<strong>Steve Jobs by Walter
Isaacson</strong>", aquí os dejamos la dirección de amazon donde
podeís adquirirla.</span></p>
-<p><span style="font-size: medium;"><a>... </p></span></a>';
+<p><span style="font-size: medium;"><a>... </a></span></p>';
$this->assertEquals($expected, $result);
}
View
12 lib/Cake/View/Helper/TextHelper.php
@@ -287,9 +287,15 @@ class_exists('Multibyte');
$bits = mb_substr($truncate, $spacepos);
preg_match_all('/<\/([a-z]+)>/', $bits, $droppedTags, PREG_SET_ORDER);
if (!empty($droppedTags)) {
- foreach ($droppedTags as $closingTag) {
- if (!in_array($closingTag[1], $openTags)) {
- array_unshift($openTags, $closingTag[1]);
+ if (!empty($openTags)) {
+ foreach ($droppedTags as $closingTag) {
+ if (!in_array($closingTag[1], $openTags)) {
+ array_unshift($openTags, $closingTag[1]);
+ }
+ }
+ } else {
+ foreach ($droppedTags as $closingTag) {
+ array_push($openTags, $closingTag[1]);
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.