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

throwing some sort of compile error if using a modifier where it won't work #526

Closed
eth8505 opened this issue Dec 17, 2018 · 4 comments
Closed
Milestone

Comments

@eth8505
Copy link

eth8505 commented Dec 17, 2018

We've been running smarty 3.1.29 for a while, since we were having problems with anything newer. Due to the CVE found in smarty we have to give upgrading another go. However, it appears that modifiers no longer work in includes.

{include|dot:"x-template-id" file="included.dot.tpl"}

The plugin is used to wrap the include result in a script tag.
With 3.1.29 the resulting html was:

<?php ob_start();
$_smarty_tpl->smarty->ext->_subtemplate->render($_smarty_tpl, "file:includes/notifications/layer_notifications.dot.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), 0, false);
echo smarty_modifier_dot(ob_get_clean(),"x-tpl-notification-layer");?>

with newer versions we only get:

<?php $_smarty_tpl->_subTemplateRender("file:includes/notifications/layer_notifications.dot.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), 0, false);
?>

Is this anything we can fix ourself with some new config I missed or is it broken?

@wisskid
Copy link
Contributor

wisskid commented Feb 19, 2020

Modifiers were not intended to be used on built in functions (as stated in the docs). It seems that applying modifiers to include did in fact work, however in 3.1.29 and prior.
In 3.1.30 compilation of templates changed quite a bit, and now it no longer works. I'm not sure what you've been trying to do here, but I'm afraid you'll have to find some other way.

@wisskid wisskid closed this as completed Feb 19, 2020
@eth8505
Copy link
Author

eth8505 commented Feb 20, 2020

@wisskid Oh, I never understood the docs that way actually, as it didn't explicitly exclude built in functions, thanks for clarifying that. What we're trying to do here is wrap a script-Tag around an include result with a modifier. It's more of a convenience function really, but we do use it a lot. We did find a workaround for that, but speaking from experience with smarty in the past it'll most likely break eventually ;-)

What I'd like to see with this is smarty throwing some sort of compile error if using a modifier where I shouldn't. Simply swallowing it seems wrong, is that something that could be done?

@wisskid
Copy link
Contributor

wisskid commented Feb 20, 2020

What I'd like to see with this is smarty throwing some sort of compile error if using a modifier where I shouldn't. Simply swallowing it seems wrong, is that something that could be done?

That seems very reasonable. I'll see if we can get that in. It would have to go into Smarty 4 as it might break existing code. Hopefully it won't break your workaround :)

@wisskid wisskid reopened this Feb 20, 2020
@wisskid wisskid changed the title 3.1.29 to 3.1.30 or higher does not apply modifier on {include} throwing some sort of compile error if using a modifier where it won't work Feb 20, 2020
@eth8505
Copy link
Author

eth8505 commented Feb 21, 2020

@wisskid great, thanks. We're working on getting rid of most of the inline-templates anyway, it's a massive app though, so you know how that goes ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants