Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smarty fails with any plugin that ends in 'close' #52

Closed
calguy1000 opened this issue Jun 10, 2015 · 5 comments
Closed

Smarty fails with any plugin that ends in 'close' #52

calguy1000 opened this issue Jun 10, 2015 · 5 comments

Comments

@calguy1000
Copy link

Sample code:

registerPlugin('function','testclose','test_plugin',false); $tpl = '{testclose}'; $smarty->display('string:'.$tpl); ?>

Error:

PHP Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "4f51b386251639c28dd52ffe53b55c127b1faa69" on line 1 "{testclose}" unknown tag "testclose" <--
thrown in /nfs/u1404/smarty_test/smarty-3.1.24/libs/sysplugins/smarty_internal_templatecompilerbase.php on line 1

Note:

Changing the plugin name to 'testfoo' and the call in the template to {testfoo} provides the expected output.

@Stricted
Copy link
Contributor

looks like https://github.com/smarty-php/smarty/blob/master/libs/sysplugins/smarty_internal_templatecompilerbase.php#L521 is the problem

echo substr($tag, - 5); above this line says 'close'
if you look at line https://github.com/smarty-php/smarty/blob/master/libs/sysplugins/smarty_internal_templatecompilerbase.php#L638 you see that the 'close' will be removed and then it will trigger the error becouse your plugin has the name 'testclose' and not 'test'

i think @uwetews need to check this

@uwetews
Copy link
Contributor

uwetews commented Jun 11, 2015

Smarty does use tag names ending with close internally to handle closing tags. Like {/foo} => fooclose.
You should not use it as a standalone plugin name.

It allows for example to write compiler plugins for block tags usage. One compiler plugin 'foo' and one for 'fooclose' to use {foo} .... {/foo}.

@uwetews uwetews closed this as completed Jun 11, 2015
@calguy1000
Copy link
Author

Well, the problem is that older versions of smarty (2.x) didn't do that...
and there are valid cases where people have written smarty plugins for
various third party packages using smarty with the name 'close' in them,
and those plugins are years old...... maybe they could have used a block
tag, but they didn't. i.e: tags like {form_open} or {form_close} or
{togglearea_open} and {togglearea_close}

And now those plugins cause an error in smarty 3.

Is it possible to change smarty in the next version to use a delimiter
like: "_smartyclose" or something that is less likely to conflict with
valid tag names.

On Thu, Jun 11, 2015 at 1:06 PM, uwetews notifications@github.com wrote:

Smarty does use tag names ending with close internally to handle closing
tags. Like {/foo} => fooclose.
You should not use it as a standalone plugin name.

It allows for example to write compiler plugins for block tags usage. One
compiler plugin 'foo' and one for 'fooclose' to use {foo} .... {/foo}.


Reply to this email directly or view it on GitHub
#52 (comment).

@uwetews
Copy link
Contributor

uwetews commented Jun 11, 2015

If I do that Smarty 3 users which have written compiler plugins for closing tags will get errors.
What I can do is to handle tags ending with "_close" like normal plugins tag.

@uwetews
Copy link
Contributor

uwetews commented Jun 27, 2015

This problem is now resolved.
Function plugins can now have names ending with 'close'.
The fix is in dev-master and will later be included in the 3.1.28 release.

think-mcunanan pushed a commit to think-mcunanan/smarty that referenced this issue Mar 22, 2023
…-reservation-information-for-reservations-registered-from-the-new-WEB-reservation-is-not-displayed-(reservation-screen-/-pop-up)

Redmine: #5314 Displaying the new reservation system notes data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants