Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

FIXED maincore 7.02.05 trimlink function bug (trapezoid with question mark)

Bug: last non-trimmed char is returning trapezoid with question mark symbol before three dots (ISO-8859-2)

e.g.:
U+0159
C5 99
LATIN SMALL LETTER R WITH CARON


maincore Function
[syntaxhighlighter brush=php,first-line=1,highlight=6,collapse=false,html-script=false]// Trim a line of text to a preferred length
function trimlink($text, $length) {
$dec = array("&", "\"", "'", "\\", '\"', "\'", "<", ">"wink;
$enc = array("&amp;", "&quot;", "&#39;", "&#92;", "&quot;", "&#39;", "&lt;", "&gt;"wink;
$text = str_replace($enc, $dec, $text);
if (strlen($text) > $length) $text = substr($text, 0, ($length-3))."...";
$text = str_replace($dec, $enc, $text);
return $text;
}[/syntaxhighlighter]

Code usage
[syntaxhighlighter brush=php,first-line=1,highlight=4,collapse=false,html-script=false]if (dbrows($result)) {
while($data = dbarray($result)) {
$itemsubject = trimlink($data['thread_subject'], 23);
echo THEME_BULLET." <a href='".FORUM."viewthread.php?thread_id=".$data['thread_id']."' title='".$data['thread_subject']."' class='side'>$itemsubject</a><br />\n";
}
} else {
echo "<div style='text-align:center'>".$locale['global_023']."</div>\n";
}[/syntaxhighlighter]
$data['thread_subject'] work well
$itemsubject issue


affected
  • forum threads panel
  • administration faq
  • administration weblink_cat
  • and others


PHP 5.2.3
MySQL Server 5.1.41-log
PHP-Fusion 7.02.05

Merged on Jan 21 2013 at 01:44:17:

Temporary fix Temporary fix Temporary fix

mb_substr
[syntaxhighlighter brush=php,first-line=1,highlight=6,collapse=false,html-script=false]// Trim a line of text to a preferred length, Petr clone9cz Jursík temp fix 7.02.05
function trimlink($text, $length) {
$dec = array("&", "\"", "'", "\\", '\"', "\'", "<", ">"wink;
$enc = array("&amp;", "&quot;", "&#39;", "&#92;", "&quot;", "&#39;", "&lt;", "&gt;"wink;
$text = str_replace($enc, $dec, $text);
if (strlen(utf8_decode($text)) > $length) $text = mb_substr($text, 0, ($length-3),'UTF-8'wink."..."; // UTF-8 FIX EN - trapezoid with question mark (CZ - lichobežník s otazníkem u zkrácených link&#367wink
$text = str_replace($dec, $enc, $text);
return $text;
}[/syntaxhighlighter]
Looks like this only for Unicode?
Had the same problem here... Included some panels on a page, and suddenly the whole encoding was messed up. It was the trim functions used in forum_threads_panel.php! Added the fix from clone9cz, workes great.

@PolarFox Well, at least when using the UTF-8 encoding. Please fix this in the next versions!
Thread Information
Author
Replies
3 posts
Views
2,794 times
Last Post
Last updated on 5 years ago
Related Threads
You can view all discussion threads in this forum.
You cannot set up a bounty in this discussion thread.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
You cannot up or down-vote on the post in this discussion thread.
Users who participated in discussion: PolarFox, clone9cz, pattyland