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

[smarty3] Problems with variable escaping.

 
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 -> General
View previous topic :: View next topic  
Author Message
weirdWeazel
Smarty n00b


Joined: 27 Feb 2014
Posts: 2

PostPosted: Thu Feb 27, 2014 2:41 pm    Post subject: [smarty3] Problems with variable escaping. Reply with quote

Hi!

I initially intended to just implement a simple escaping when displaying a form with submitted form values, which should be escaped. That's it.

When searching for ways to do it with smarty, I mostly found the answer 'upgrade to Smarty 3' which I then did. (2.6.26 to 3.1.16).

After a pretty long search I found out that I may enable escaping either with
Code:
$smarty->default_modifiers = array('escape:"htmlall"');

or
Code:
$smarty->escape_html = TRUE;


They both have the same effect and both after I reset the templates.

Problem is, they escape EVERY variable in a way, that the HTML templates won't get rendered but displayed as markup.

Example:
Code:
<div class="box left "> <h1>Hi  tester!</h1> <div class="wrap large">...


This should be displayed as correctly style box and not as HTML code.

The documentation about these features is really sparse and I couldn't find the problem I'm having either here in this forum or at stackoverflow, so I created my own thread. Sorry, if this has been answered, I didn't find any answer.

Also: Is there a way to JUST escape forms without building my own filter?

That would be great!
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Thu Feb 27, 2014 3:42 pm    Post subject: Reply with quote

You can disable escaping from single variables by adding the nofilter flag: {$variable nofilter}.

See http://www.smarty.net/docs/en/variable.escape.html.tpl
Back to top
View user's profile Send private message
weirdWeazel
Smarty n00b


Joined: 27 Feb 2014
Posts: 2

PostPosted: Thu Feb 27, 2014 3:43 pm    Post subject: Reply with quote

U.Tews wrote:
You can disable escaping from single variables by adding the nofilter flag: {$variable nofilter}.

See http://www.smarty.net/docs/en/variable.escape.html.tpl


Hi, thank you, I know.

But the problem is, that the whole template is not being rendered but escaped. If I added the 'nofilter' the variables on the layer below wouldn't be escaped either - or would they?
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 -> General 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