strpos error in helper file

  • Christian Wolkersdorfer
13 years 5 months ago #198 by Christian Wolkersdorfer
strpos error in helper file was created by Christian Wolkersdorfer
joodb 1.5B3 (Joomla 1.5.22) caused an error message in strpos (helper.php) in some situations where the string contained non printable characters. The reason is in function wrapText. Modifying your function to the following version eliminates the bug
/**
* Shorten a text
*
* @access public
* @param String with text, Integer with maximum length
*/
function wrapText($text,$maxlen=120) {
$text = strip_tags($text);
if (strlen($text)>$maxlen) {
$len = strpos($text," ",$maxlen);
if ($len) $text = substr($text,0,$len).' …';
}
return $text;
}
Kind regards und beste Grüße and die Programmierer einer hilfreichen Komponente!

Ch Wolkersdorfer

Please Log in to join the conversation.

12 years 2 months ago #645 by
Replied by on topic Re:strpos error in helper file
I had this exact problem, found your post and it fixed me right up, thanks Christian Wolkersdorfer! I just replaced lines 240-253 in joodb.php with your code (JooDB v1.6, Joomla 1.7.3).
Warning: strpos() [function.strpos]: Offset not contained in string in ../components/com_joodb/helpers/joodb.php on line 249

Please Log in to join the conversation.

Moderators: Dirkjoest