Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

usage of uniqid() to define function name (content_)

 
Post new topic   Reply to topic    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
bobdoll
Smarty n00b


Joined: 09 Nov 2011
Posts: 1

PostPosted: Wed Nov 09, 2011 1:53 pm    Post subject: usage of uniqid() to define function name (content_) Reply with quote

Hi,

PHP uniqid() can include a '.' (dot) in some case which. Uniqid is use to defune 'unifunc' which is then used as a function name if the '.' gets in there it become a PHP error.

sysplugins/smarty_internal_template.php :
BUG : $this->properties['unifunc'] = 'content_' . uniqid();
BETTER : $this->properties['unifunc'] = 'content_' . str_replace('.', '_',uniqid());


Reproduce : i get this on cygwin PHP 5.3.8

I changed my file, hope to see this uniqid usage fixed in the next version.

Best,
Bob.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Wed Nov 09, 2011 3:14 pm    Post subject: Reply with quote

I just found this:

https://bugs.php.net/bug.php?id=34908

So cygwin does use a different default value for $more_entropy parameter of uniqid() and this is not documented.

Anyway we will update our code with the next release.
Back to top
View user's profile Send private message
kowach
Smarty Rookie


Joined: 26 Jan 2011
Posts: 13

PostPosted: Mon Feb 17, 2014 1:42 pm    Post subject: Reply with quote

Same bug rises again when executing PHP on HHVM (Hip Hop 2.4).

On hhvm uniqid('', true) returns "," instead "."

So you should replace
'content_' . str_replace('.', '_',uniqid());
to
'content_' . str_replace(array('.',','), '_',uniqid());

best regards,
Kowach
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Mon Feb 17, 2014 6:26 pm    Post subject: Reply with quote

Thanks for your input.

The fix is now in the SVN trunk and will later be included in 3.1.17
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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