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

Unexpected input at line x smarty_internal_templatelexer.php

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


Joined: 06 Sep 2018
Posts: 6

PostPosted: Thu Sep 06, 2018 8:58 am    Post subject: Unexpected input at line x smarty_internal_templatelexer.php Reply with quote

Hey there,

after distributing a Smarty update from 3.1.30 to 3.1.32, several customer's websites crashed with the following message:

Code:

Fatal error: Uncaught exception 'Exception' with message 'Unexpected input at line3: ' in sysplugins/smarty_internal_templatelexer.php:357
Stack trace:
#0 sysplugins/smarty_internal_templatelexer.php(255): Smarty_Internal_Templatelexer->yylex1()
#1 sysplugins/smarty_internal_smartytemplatecompiler.php(113): Smarty_Internal_Templatelexer->yylex()
#2 sysplugins/smarty_internal_templatecompilerbase.php(423): Smarty_Internal_SmartyTemplateCompiler->doCompile('{{* Inline Fron...', true)
#3 sysplugins/smarty_internal_templatecompilerbase.php(351): Smarty_Internal_TemplateCompilerBase->compileTemplateSource(Object(Smarty_Internal_Template), NULL, NULL)
#4 sysplugins/smarty_template_compiled.php(184): Smarty_Internal in sysplugins/smarty_internal_templatelexer.php on line 357


The line number varies. It only happens in CSS templates, with {{ and }} set as delimeters.

I've experimented escaping parts of the template with {{literal}}, which resolved it sometimes, but I can't determine the logic behind the bug.

In one case, I could resolve it by escaping a >:
Code:

... more css code before this...

.info .alerts {{literal}}>{{/literal}} div.cmstooltip_container_sensor {
    display: inline-block;
    width: 100%;
    height: 40px;
    text-align: center;
}
... more css code after this...


So I figured the problem was that character, but it also happened in another stylesheet where that character was not used. Strangely, I could resolve it there by inserting a comment at a seemingly random point:

Code:

... more css code before this...

.header.fixed .inner {
    padding:10px 0;
}

{{* This comment is a workaround for a smarty bug *}}

.header.fixed .inner .logo a img {
    height: 40px;
}
... more css code after this...


I've checked if there are weird hidden characters or unclosed css braces at that part or the rest of the stylesheet, but there aren't. Moving the comment further up in the code will bring the error back. Moving it further down will work to a degree, but too far down will also bring the error back. I can supply the full tpl, if you need it.

Thank you!
Back to top
View user's profile Send private message
LMan
Smarty Rookie


Joined: 06 Sep 2018
Posts: 6

PostPosted: Thu Sep 06, 2018 9:00 am    Post subject: Addition Reply with quote

Side note, we've googled the error and tried turning up pcre.backtrack_limit, as suggested for this error message. But that didn't resolve the issue, and as mentioned the sites were running fine in 3.1.30
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1399

PostPosted: Thu Sep 06, 2018 11:16 am    Post subject: Reply with quote

You do realize, that without a reproducible test case, it is impossible to debug your issue?
Back to top
View user's profile Send private message
LMan
Smarty Rookie


Joined: 06 Sep 2018
Posts: 6

PostPosted: Thu Sep 06, 2018 11:50 am    Post subject: Reply with quote

https://markus-klein-artwork.de/services/files/smarty/test-case.7z

Here you are. Since the original offending tpl did not throw an error in the test scenario, I figured it might relate to the overall length. So by duplicating its content up to 5000 lines, I managed to trigger it:

Fatal error: Uncaught exception 'Exception' with message 'Unexpected input at line4: ' in sysplugins/smarty_internal_templatelexer.php:357
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1399

PostPosted: Thu Sep 06, 2018 12:29 pm    Post subject: Reply with quote

Thanks. Have you tried it on the .33-dev ?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1399

PostPosted: Thu Sep 06, 2018 12:51 pm    Post subject: Reply with quote

I'm unable to reproduce your issue with both 3.1.32 and 3.1.33-dev-12.
Both with PHP 5.6.37 and PHP 7.1.21
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1399

PostPosted: Thu Sep 06, 2018 2:59 pm    Post subject: Reply with quote

https://github.com/AnrDaemon/test-001/tree/forum-27414
Back to top
View user's profile Send private message
LMan
Smarty Rookie


Joined: 06 Sep 2018
Posts: 6

PostPosted: Fri Sep 07, 2018 10:07 am    Post subject: Reply with quote

Just tried it with 3.1.33-dev, the problem persists.

PHP version 5.3.3

It's not super critical since I can work around it, just thought you'd want to know the issue exists.

Since there is no direct explaination, I could imagine it being related to Smarty .32 doing something *different* compared to .30, that while not being "wrong" might consume more resouces or trigger some other crap within PHP, resulting in the crash. I'll try to migrate the affected pages to PHP7 and let you know if that resolves the issue.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1399

PostPosted: Fri Sep 07, 2018 7:16 pm    Post subject: Reply with quote

Smarty: 3.1.33-dev-12
PHP: 5.3.29

Not reproducible.
Sorry, butů you gotta try to dig deeper Smile

One very small note, in case you would be looking through it.
Since upgrade to .32, I've been having a problem with one of my old templates, it was behaving weirdly, spilling PHP code out of cached pages.
I was intending to rewrite that old code/template anyway, so I did and problem went away unresolved, but my guess is that there's some weird output buffer stacking going on, that's not always consistent or contained.
But the problem was exposed only when I turn on page caching. If I set caching to off, and clear compiled/cached templates, the problem go away.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Sun Oct 14, 2018 1:50 am    Post subject: Reply with quote

This was a bug on some very large plain text sections, without any Smarty tags.
This has been fixed in the github master branch and will be included in 3.1.34
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