Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Bug in modifier.truncate.php

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
Mindfactory
Smarty n00b


Joined: 07 Jul 2010
Posts: 1

PostPosted: Wed Jul 07, 2010 9:37 am    Post subject: Bug in modifier.truncate.php Reply with quote

Dear Smarty-Community,

we don’t know if you already knew this bug, so we add it here for help.

in Smarty version 3 we found a bug in the file named "modifier.truncate.php"

Line 37:

$string = preg_replace('/\s+?(\S+)?$/u', '', mb_substr($string, 0, $length + 1));

The modifier "u" isn’t a good choice for the german language, because of its umlauts. (Ä, ä, Ö, ö, Ü, ü und ß).

Following you’ll find a little example:

<?php
$text = "Ä oder ä, Ö oder ö, Ü oder ü und ß. Ein Text mit Umlauten.";
$string = preg_replace('/\s+?(\S+)?$/u', '', mb_substr($text, 0, 50));
$string2 = preg_replace('/\s+?(\S+)?$/', '', mb_substr($text, 0, 50));

echo '<pre>';
print_r('Text: '.$text);
echo '</pre>';

echo '<pre>';
print_r('Ausgabe1: '.$string);
echo '</pre>';

echo '<pre>';
print_r('Ausgabe2: '.$string2);
echo '</pre>';

exit;
?>

Liebe Smarty-Community,

wir wissen nicht ob dieser Bug schon bekannt ist, deshalb melden wir ihn hier.

in Version 3 haben wir ein Bug entdeckt und zwar in der Datei "modifier.truncate.php".

Zeile 37:

$string = preg_replace('/\s+?(\S+)?$/u', '', mb_substr($string, 0, $length + 1));

Modifier "u" ist für die Deutsche Sprache nicht geeignet, da sie Umlaute (Ä, ä, Ö, ö, Ü, ü und ß) hat.
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Jul 07, 2010 12:12 pm    Post subject: Reply with quote

Where is the problem?
"isn’t a good choice" is no valid bug report.
You missed to mention what output you expect and what output you get instead.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ChrisFah
Smarty Pro


Joined: 02 Nov 2009
Posts: 159
Location: Traun, Austria

PostPosted: Wed Jul 07, 2010 4:13 pm    Post subject: Reply with quote

Hi, möchte auch meinen Senf dazugeben, da beide ja deutsch können:

Ich seh das Problem nicht beim Modifier.
Das Problem liegt am Text, der nach der Eingabe nciht auf "german umlauts" geprüft und gegebenfalls durch &?uml; usw korrigiert wurde...

Lg, Chris
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Jul 07, 2010 4:42 pm    Post subject: Reply with quote

In Smarty3 we added multibyte support. But in the trucate modifer we need to check if the string is utf-8 encoded or not.

This has been fixed in the SVN now.
Back to top
View user's profile Send private message
freemylove
Smarty Rookie


Joined: 20 Jul 2010
Posts: 9

PostPosted: Tue Jul 20, 2010 1:37 pm    Post subject: Reply with quote

thanks
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3 All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP