Author: fabien
Date: 2010-05-12 08:53:36 +0200 (Wed, 12 May 2010)
New Revision: 29417
Modified:
branches/1.3/lib/helper/TextHelper.php
branches/1.3/test/unit/helper/TextHelperTest.php
branches/1.4/lib/helper/TextHelper.php
branches/1.4/test/unit/helper/TextHelperTest.php
Log:
[1.3, 1.4] fixed strip_links_text() from TextHelpers is defective and does not
handle multiple links (closes #8589)
Modified: branches/1.3/lib/helper/TextHelper.php
===================================================================
--- branches/1.3/lib/helper/TextHelper.php 2010-05-12 06:36:19 UTC (rev
29416)
+++ branches/1.3/lib/helper/TextHelper.php 2010-05-12 06:53:36 UTC (rev
29417)
@@ -213,7 +213,7 @@
*/
function strip_links_text($text)
{
- return preg_replace('/<a.*>(.*)<\/a>/m', '\\1', $text);
+ return preg_replace('/<a[^>]*>(.*?)<\/a>/s', '\\1', $text);
}
if (!defined('SF_AUTO_LINK_RE'))
Modified: branches/1.3/test/unit/helper/TextHelperTest.php
===================================================================
--- branches/1.3/test/unit/helper/TextHelperTest.php 2010-05-12 06:36:19 UTC
(rev 29416)
+++ branches/1.3/test/unit/helper/TextHelperTest.php 2010-05-12 06:53:36 UTC
(rev 29417)
@@ -13,7 +13,7 @@
require_once(dirname(__FILE__).'/../../../lib/helper/TagHelper.php');
require_once(dirname(__FILE__).'/../../../lib/helper/TextHelper.php');
-$t = new lime_test(51);
+$t = new lime_test(52);
// truncate_text()
$t->diag('truncate_text()');
@@ -108,6 +108,7 @@
// text_strip_links()
$t->diag('text_strip_links()');
$t->is(strip_links_text("<a href='almost'>on my mind</a>"), "on my mind",
'text_strip_links() strips all links in input');
+$t->is(strip_links_text('<a href="first.html">first</a> and <a
href="second.html">second</a>'), "first and second", 'text_strip_links() strips
all links in input');
// auto_link_text()
$t->diag('auto_link_text()');
Modified: branches/1.4/lib/helper/TextHelper.php
===================================================================
--- branches/1.4/lib/helper/TextHelper.php 2010-05-12 06:36:19 UTC (rev
29416)
+++ branches/1.4/lib/helper/TextHelper.php 2010-05-12 06:53:36 UTC (rev
29417)
@@ -213,7 +213,7 @@
*/
function strip_links_text($text)
{
- return preg_replace('/<a.*>(.*)<\/a>/m', '\\1', $text);
+ return preg_replace('/<a[^>]*>(.*?)<\/a>/s', '\\1', $text);
}
if (!defined('SF_AUTO_LINK_RE'))
Modified: branches/1.4/test/unit/helper/TextHelperTest.php
===================================================================
--- branches/1.4/test/unit/helper/TextHelperTest.php 2010-05-12 06:36:19 UTC
(rev 29416)
+++ branches/1.4/test/unit/helper/TextHelperTest.php 2010-05-12 06:53:36 UTC
(rev 29417)
@@ -13,7 +13,7 @@
require_once(dirname(__FILE__).'/../../../lib/helper/TagHelper.php');
require_once(dirname(__FILE__).'/../../../lib/helper/TextHelper.php');
-$t = new lime_test(51);
+$t = new lime_test(52);
// truncate_text()
$t->diag('truncate_text()');
@@ -108,6 +108,7 @@
// text_strip_links()
$t->diag('text_strip_links()');
$t->is(strip_links_text("<a href='almost'>on my mind</a>"), "on my mind",
'text_strip_links() strips all links in input');
+$t->is(strip_links_text('<a href="first.html">first</a> and <a
href="second.html">second</a>'), "first and second", 'text_strip_links() strips
all links in input');
// auto_link_text()
$t->diag('auto_link_text()');
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.