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:'javascript' bug

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


Joined: 07 Apr 2012
Posts: 6

PostPosted: Sat Apr 07, 2012 1:19 am    Post subject: escape:'javascript' bug Reply with quote

I've just recently upgraded from 3.0.X to 3.1.8 (yeah I know, kinda lazy) and run into what appears to be an javascript escape bug.

The code that is bugging out is just:

var address = '{$address|escape:'javascript'}';

This used to work fine until I updated. Now it results in:

[07-Apr-2012 01:06:53 UTC] PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /domain/project/.smarty/templates_c/cf8565858795dac5032f8acef6d6d90aecff0674.file.index.tpl.cache.php on line 220

When I get rid of the 'javascript' the script is unbroken, but obviously it's defaulting.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Sat Apr 07, 2012 5:26 pm    Post subject: Reply with quote

I can't reproduce the problem.

How does line 220 in /domain/project/.smarty/templates_c/cf8565858795dac5032f8acef6d6d90aecff0674.file.index.tpl.cache.php look like?
Back to top
View user's profile Send private message
Insomniac
Smarty Rookie


Joined: 07 Apr 2012
Posts: 6

PostPosted: Sat Apr 07, 2012 7:48 pm    Post subject: Reply with quote

Exact line of the template

Code:
var address = '{$address|escape:'javascript'}';


Compiled code:

Code:
var address = '<?php echo '/*%%SmartyNocache:10677328934f8099498848b1-39097272%%*/<?php echo strtr($_smarty_tpl->tpl_vars[\'address\']->value, array("\\\" => "\\\\\\", "\'" => "\\\\'", "\"" => "\\\\"", "\r" => "\\\r", "\n" => "\\\n", "</" => "<\/" ));?>
/*/%%SmartyNocache:10677328934f8099498848b1-39097272%%*/';?>
';
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Sun Apr 08, 2012 12:10 pm    Post subject: Reply with quote

This bug did occur within nocache sections.
The fix is now in the SVN trunk and will later be included in 3.1.9
Back to top
View user's profile Send private message
Insomniac
Smarty Rookie


Joined: 07 Apr 2012
Posts: 6

PostPosted: Sun Apr 08, 2012 9:03 pm    Post subject: Reply with quote

Thanks for that. I tried searching for a reference to the bug, but no luck.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Mon Apr 09, 2012 10:18 am    Post subject: Reply with quote

The error was not directly related to the escape modifier but the nocache code compiler.

- bugfix "\\" was not escaped correctly when generating nocache code (Forum Topic 21364)
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