summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2009-02-03 15:51:00 +0100
committerDerek Jones <derek.jones@ellislab.com>2009-02-03 15:51:00 +0100
commit01d6b4f663588e80ca43deafc40090c910eb4b35 (patch)
tree99c073dae2ef75db8b9a3518b3ba31343e79f67f /system/helpers
parent33559103ddf02648837c85ed72425ac06c06080c (diff)
Fixed a bug where the end character was being added when the character limit's limit intersected the last word of the string.
http://expressionengine.com/forums/viewthread/103748/
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/text_helper.php10
1 files changed, 6 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)