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

UTF-8 and outputfilter.trimwhitespace.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 -> Bugs
View previous topic :: View next topic  
Author Message
yaseek
Smarty n00b


Joined: 28 May 2007
Posts: 4

PostPosted: Mon Jul 09, 2007 9:48 am    Post subject: UTF-8 and outputfilter.trimwhitespace.php Reply with quote

...so, if you try to use UTF-8 symbols in a <script > ... </script> block (assign utf8-strings to js vars for example) and then apply the trimwhitespace filter to output - your script block will be lost from result...

ps: in my case all string and regexp functions are overloaded by mb_ functions, but i'm not sure that affect this problem.
---
THNX, yaseek


Last edited by yaseek on Wed May 05, 2010 10:51 pm; edited 1 time in total
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon Jul 09, 2007 10:35 am    Post subject: Reply with quote

Hi.

I'm not sure I understand precisely but the trimwhitespace filter mangles <script> blocks via a PHP preg_replace() call. Is that case covered by your mb_ changes that you mentioned?
Back to top
View user's profile Send private message
yaseek
Smarty n00b


Joined: 28 May 2007
Posts: 4

PostPosted: Mon Jul 09, 2007 1:41 pm    Post subject: Reply with quote

boots wrote:
Hi.

I'm not sure I understand precisely but the [url=http://cvs.php.net/viewvc.cgi/smarty/libs/plugins/outputfilter.trimwhitespace.php?view=markup]trimwhitespace filter mangles &lt;script&gt; blocks via a PHP preg_replace() call. Is that case covered by your mb_ changes that you mentioned?

hmm, may be error in mb_preg_replace()? Smile
...i'll test it tomorrow[/url]


Last edited by yaseek on Wed May 05, 2010 10:51 pm; edited 1 time in total
Back to top
View user's profile Send private message
yaseek
Smarty n00b


Joined: 28 May 2007
Posts: 4

PostPosted: Fri Aug 31, 2007 11:00 am    Post subject: Reply with quote

boots wrote:
Hi.

I'm not sure I understand precisely but the [url=http://cvs.php.net/viewvc.cgi/smarty/libs/plugins/outputfilter.trimwhitespace.php?view=markup]trimwhitespace filter mangles &lt;script&gt; blocks via a PHP preg_replace() call. Is that case covered by your mb_ changes that you mentioned?

Function substr_replace() in smarty_outputfilter_trimwhitespace_replace() dosn't have an mb_ reflection Smile If page contains an utf8-symbols your filter dosn't work.
Solution:
change $subject = substr_replace($subject, $replace[$_i], $_pos, $_len);
with $subject = preg_replace('/'.$search_str.'/', $replace[$_i], $subject, 1);
...and this will work ok in all cases (ascii/utf8)[/url]
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 -> Bugs 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