summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/helpers/text_helper.php10
-rw-r--r--user_guide/changelog.html1
2 files changed, 7 insertions, 4 deletions
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index e79a2419d..fa1de8bc6 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -87,14 +87,16 @@ if ( ! function_exists('character_limiter'))
{
return $str;
}
-
+
$out = "";
foreach (explode(' ', trim($str)) as $val)
{
- $out .= $val.' ';
+ $out .= $val.' ';
+
if (strlen($out) >= $n)
{
- return trim($out).$end_char;
+ $out = trim($out);
+ return (strlen($out) == strlen($str)) ? $out : $out.$end_char;
}
}
}
@@ -236,7 +238,7 @@ if ( ! function_exists('word_censor'))
// \w, \b and a few others do not match on a unicode character
// set for performance reasons. As a result words like über
// will not match on a word boundary. Instead, we'll assume that
- // a bad word will be bookeneded by any of these characters.
+ // a bad word will be bookended by any of these characters.
$delim = '[-_\'\"`(){}<>\[\]|!?@#%&,.:;^~*+=\/ 0-9\n\r\t]';
foreach ($censored as $badword)
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 501529658..90cc7cac9 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -107,6 +107,7 @@ SVN Revision: </p>
<li>Fixed a bug in database escaping where a compound statement (ie: SUM()) wasn't handled correctly with database prefixes.</li>
<li>Fixed a bug when an opening quote is preceded by a paragraph tag and immediately followed by another tag.</li>
<li>Fixed a bug in the Text Helper affecting some locales where word_censor() would not work on words beginning or ending with an accented character.</li>
+ <li>Fixed a bug in the Text Helper character limiter where the provided limit intersects the last word of the string.</li>
<li>Tweaked Typography::auto_typography() for some edge-cases.</li>
</ul>