|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
gyopee Smarty Rookie
Joined: 27 Jan 2014 Posts: 14
|
Posted: Wed Jul 30, 2014 10:39 am Post subject: escape modifier |
|
|
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:
<i>text</i>
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Jul 30, 2014 1:41 pm Post subject: |
|
|
tested latest smarty version:
Code: | {"<i>text</i>"}
{"<i>text</i>"|escape}
{"<i>text</i>"|escape:"UTF-8":false} |
result:
Code: | <i>text</i>
<i>text</i>
<i>text</i> |
Is that not what you are getting? |
|
Back to top |
|
gyopee Smarty Rookie
Joined: 27 Jan 2014 Posts: 14
|
Posted: Thu Jul 31, 2014 7:28 am Post subject: |
|
|
First problem:
I think these should be the same:
Code: |
{"<i>&text&</i>"|escape}
{"<i>&text&</i>"|escape:"UTF-8":true}
|
But the output is:
Code: |
<i>&amp;text&amp;</i>
<i>&text&</i>
|
Second problem:
If I use this in PHP:
Code: |
$a = "<i>&text&</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>&text&</i>
<i>&amp;text&amp;</i>
<i>&text&</i>
|
That's okay.
The same in smarty:
Code: |
{"<i>&text&</i>"}
{"<i>&text&</i>"|escape}
{"<i>&text&</i>"|escape:"UTF-8":false}
|
Writes out this:
Code: |
<i>&text&</i>
<i>&amp;text&amp;</i>
<i>&text&</i>
|
That doesn't seem to be okay. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
|
Back to top |
|
gyopee Smarty Rookie
Joined: 27 Jan 2014 Posts: 14
|
Posted: Thu Jul 31, 2014 4:55 pm Post subject: |
|
|
You are absolutely right.
Thank you and sorry for my inattention. |
|
Back to top |
|
|
|
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
|