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

escape modifier

 
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
gyopee
Smarty Rookie


Joined: 27 Jan 2014
Posts: 14

PostPosted: Wed Jul 30, 2014 10:39 am    Post subject: escape modifier Reply with quote

Hi,

1. For this input:
{"<i>text</i>"}
I expect this html output:
text

2. For this input:
{"<i>text</i>"|escape}
I expect this html output because of the default double encoding:
&lt;i&gt;text&lt;/i&gt;

3. For this input:
{"<i>text</i>"|escape:"UTF-8":false}
I expect this html output:
<i>text</i>

In the 2nd case It's not working as I expected. I get this as html output:
<i>text</i>

Am I thinking in the wrong way or is this a bug?

Thanks.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Jul 30, 2014 1:41 pm    Post subject: Reply with quote

tested latest smarty version:

Code:
{"<i>text</i>"}
{"<i>text</i>"|escape}
{"<i>text</i>"|escape:"UTF-8":false}


result:

Code:
<i>text</i>
&lt;i&gt;text&lt;/i&gt;
<i>text</i>


Is that not what you are getting?
Back to top
View user's profile Send private message Visit poster's website
gyopee
Smarty Rookie


Joined: 27 Jan 2014
Posts: 14

PostPosted: Thu Jul 31, 2014 7:28 am    Post subject: Reply with quote

First problem:
I think these should be the same:
Code:

{"<i>&amp;text&amp;</i>"|escape}
{"<i>&amp;text&amp;</i>"|escape:"UTF-8":true}

But the output is:
Code:

&lt;i&gt;&amp;amp;text&amp;amp;&lt;/i&gt;
<i>&amp;text&amp;</i>


Second problem:
If I use this in PHP:
Code:

$a = "<i>&amp;text&amp;</i>";
echo $a."\n";
echo htmlspecialchars($a,ENT_QUOTES,"UTF-8",true)."\n";
echo htmlspecialchars($a,ENT_QUOTES,"UTF-8",false);


I get this:
Code:

<i>&amp;text&amp;</i>
&lt;i&gt;&amp;amp;text&amp;amp;&lt;/i&gt;
&lt;i&gt;&amp;text&amp;&lt;/i&gt;


That's okay.

The same in smarty:
Code:

{"<i>&amp;text&amp;</i>"}
{"<i>&amp;text&amp;</i>"|escape}
{"<i>&amp;text&amp;</i>"|escape:"UTF-8":false}


Writes out this:
Code:

<i>&amp;text&amp;</i>
&lt;i&gt;&amp;amp;text&amp;amp;&lt;/i&gt;
<i>&amp;text&amp;</i>


That doesn't seem to be okay.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Thu Jul 31, 2014 4:49 pm    Post subject: Reply with quote

You missed the first parameter of the escape modifier.

it must be
Code:
{"<i>&amp;text&amp;</i>"|escape:'htmlall':"UTF-8":false}

See http://www.smarty.net/docs/en/language.modifier.escape.tpl
Back to top
View user's profile Send private message
gyopee
Smarty Rookie


Joined: 27 Jan 2014
Posts: 14

PostPosted: Thu Jul 31, 2014 4:55 pm    Post subject: Reply with quote

You are absolutely right.
Thank you and sorry for my inattention.
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