Hi Mike,

my question... see at the bottom...


On  Fr 09 Dez 2016 16:08:10 CET, mike_w wrote:

Package: smarty3
Version: 3.1.30-1
Severity: important

After upgrade to 3.1.30 on Debian testing some templates failed to compile with the fatal error

[:error] [pid 1203] [client 127.0.0.1:35140] PHP Fatal error: Uncaught Exception: Error: lexing failed because a rule matched an empty string. Input "0}\n ... state TAGBODY in /usr/share/php/smarty3/sysplugins/smarty_internal_templatelexer.php:566\nStack trace:\n#0 /usr/share/php/smarty3/sysplugins/smarty_internal_templatelexer.php(263): Smarty_Internal_Templatelexer->yylex3()\n#1 /usr/share/php/smarty3/sysplugins/smarty_internal_smartytemplatecompiler.php(109): Smarty_Internal_Templatelexer->yylex()\n#2 /usr/share/php/smarty3/sysplugins/smarty_internal_templatecompilerbase.php(404): Smarty_Internal_SmartyTemplateCompiler->doCompile('<!DOCTYPE html ...',
true)\n#3
/usr/share/php/smarty3/sysplugins/smarty_internal_templatecompilerbase.php(335):
Smarty_Internal_TemplateCompilerBase->compileTemplateSource(Object(Smarty_Internal_Template), false, NULL)\n#4 /usr/share/php/smarty3/sysplugins/smarty_template_compiled.php(199): Smarty_Internal_TemplateCompilerBase->compileTemplate(Object(Smarty_Internal_Template))\n#5 /usr/share/php/smarty3/sysplugins/smarty_template_compiled.php(98) in /usr/share/php/smarty3/sysplugins/smarty_internal_templatelexer.php on line 566

putting some trace in smarty_internal_templatelexer.php function yylex3() points to a problem with template code with a literal number 0 on the rhs of a test
within {if}

Error is reproduced with a clean install of Debian testing (Virtualbox) running CLI with a minimal test script

<?php
require_once '/usr/share/php/smarty3/Smarty.class.php';
$smarty=new Smarty();
$smarty->setTemplateDir('/home/www/test/template');
$smarty->setCompileDir('/home/www/test/compile');

$smarty->assign('foo', 0);
$smarty->assign('data', 1);
$smarty->display(__FILE__);

__HALT_COMPILER();
?>
  {if $foo==0}
    <p>{$data}</p>
  {/if}
  {$smarty.version}

if $foo==0 is replaced by a literal other than 0 e.g. $foo==1 then compiling passes
$foo==42-42 works
not assigning a value to $foo makes no difference.
Disabling opcache makes no difference.
Once a template is compiled successfully with a value other than 0, changing back to literal 0 fails on first pass only.


comparing file 'smarty_internal_templatelexer.php'
extracted from github https://github.com/smarty-php/smarty/archive/v3.1.30.tar.gz extracted from debian testing http://http.debian.net/debian/pool/main/s/smarty3/smarty3_3.1.30.orig.tar.gz
Files are identical

extracted from github and either package installed or
extracted from /var/cache/apt/archives/smarty3_3.1.30-1_all.deb
Files differ

After substituting function yylex3 in installed file with that from github test script compiles and correctly returns
    <p>1</p>
    3.1.30

Good catch. However, this probably needs to get fixed in smarty-lexer, right? We cannot ship generated code in smarty3, we must generate it. That's what smarty-lexer is for. Any clue where the actuall bug is?

Please let me know if you agree that this bug should be reassigned to smarty-lexer.

Have you tried contacting upstream on this? Any help on this is highly appreciated. Ideally a patch that needs to be applied to smarty3 or smarty-lexer.

Mike

--

DAS-NETZWERKTEAM
mike gabriel, herweg 7, 24357 fleckeby
mobile: +49 (1520) 1976 148
landline: +49 (4354) 8390 139

GnuPG Fingerprint: 9BFB AEE8 6C0A A5FF BF22  0782 9AF4 6B30 2577 1B31
mail: mike.gabr...@das-netzwerkteam.de, http://das-netzwerkteam.de

Attachment: pgpvhbkj12YF1.pgp
Description: Digitale PGP-Signatur

Reply via email to