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 no longer accepts TRUE, FALSE, NULL #282

Closed
iOvergaard opened this issue Sep 2, 2016 · 2 comments
Closed

Smarty no longer accepts TRUE, FALSE, NULL #282

iOvergaard opened this issue Sep 2, 2016 · 2 comments

Comments

@iOvergaard
Copy link

Since around version 3.1.23 it seems (this commit) Smarty will no longer accept TRUE, FALSE and NULL as language structures (uppercase), but will instead try and access them like constants, which in turn could be disallowed by the security settings.

sysplugins/smarty_security.php:

public function isTrustedConstant($const, $compiler)
{
    if (in_array($const, array('true', 'false', 'null'))) {
        return true;
    }
    [...]
}

The in_array function in PHP is case sensitive, while PHP in fact allows uppercase structures (even though they are inherently slower), using them in a Smarty template will not work.

I was wondering if this is on purpose to try and enforce a better code style?

@iOvergaard
Copy link
Author

I should add that the obvious fix is to validate the constants as lowercase in this particular case, but I do not know if this opens up for invulnerabilities?

if (in_array(strtolower($const), array('true', 'false', 'null'))) {
    return true;
}

@uwetews
Copy link
Contributor

uwetews commented Sep 6, 2016

This bug is now fixed in the master branch

@uwetews uwetews closed this as completed Sep 6, 2016
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

2 participants