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

Warning on auto_literal and mbstring.func_overload

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


Joined: 15 Nov 2004
Posts: 13
Location: Trst

PostPosted: Sun Mar 16, 2014 5:03 pm    Post subject: Warning on auto_literal and mbstring.func_overload Reply with quote

Hello all.

I'm getting a repeated warning in Smarty 3.1.17/PHP 5.3.15. This only happens if $smarty->auto_literal is set to true and mbsting.func_overload is either 2, 6 or 7. The warning says:

Code:
Warning: mb_strpos(): Empty delimiter in (omitted...)\smarty\sysplugins\smarty_internal_templatelexer.php on line 316


This is the complete function (starts on line 313):
Code:
function yy_r1_13($yy_subpatterns)
    {

  if ($this->smarty->auto_literal && ($this->mbstring_overload ? (mb_strpos(" \n\t\r",mb_substr($this->value,$this->ldel_length - 1,1,'latin1'),0,'latin1') !== false) : (strpos(" \n\t\r",substr($this->value,$this->ldel_length - 1,1)) !== false))) {
    $this->token = Smarty_Internal_Templateparser::TP_TEXT;
  } else {
     $this->token = Smarty_Internal_Templateparser::TP_LDEL;
     $this->yypushstate(self::SMARTY);
     $this->taglineno = $this->line;
  }
    }

Other mbstring settings, if needed to replicate:
mbstring.internal_encoding = UTF-8
mbstring.http_output = UTF-8
mbstring.encoding_translation = On

At line 316 of smarty_internal_templatelexer.php I see that mb_substr($this->value,$this->ldel_length,1,'latin1')) evaluates to false, $this->value is '{' and $this->ldel_length is 1. The template is utf-8 without BOM.

The warning goes away and the template is rendered correctly if I substitute the '$this->ldel_length' part with '$this->ldel_length - 1' as second argument to both the mb_substr() and substr() function calls. Could it be an 'off by one' error?

djn
Back to top
View user's profile Send private message Visit poster's website
U.Tews
Administrator


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

PostPosted: Mon Mar 17, 2014 7:06 pm    Post subject: Reply with quote

This has been fixed now in the SVN trunk and will later be included in 3.1.18
Back to top
View user's profile Send private message
djn
Smarty Rookie


Joined: 15 Nov 2004
Posts: 13
Location: Trst

PostPosted: Tue Mar 18, 2014 12:26 am    Post subject: Reply with quote

Very Happy
Back to top
View user's profile Send private message Visit poster's website
U.Tews
Administrator


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

PostPosted: Thu Mar 20, 2014 10:15 pm    Post subject: Reply with quote

Previous fix was buggy.
The final fix is now in the trunk.
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