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

Craft::$app->security->validateData() returns empty string in Twig when invalid value used #4387

Closed
piotrpog opened this issue Jun 10, 2019 · 3 comments

Comments

@piotrpog
Copy link

piotrpog commented Jun 10, 2019

I'm not really sure if it counts as bug.

When i use Craft::$app->security->validateData() equivalent in twig - craft.app.security.validateData('hashes_string'), and i place something else then proper hashed data in parameter, it returns empty string instead of false. Docs mention it should be checked for false value:

$foo = Craft::$app->request->getPost('foo');
$foo = Craft::$app->security->validateData($foo);

if ($foo !== false) {
    // data is valid
}
@brandonkelly
Copy link
Member

It’s the exact same function, so false will definitely be returned.

What is your template code?

@piotrpog
Copy link
Author

When i use this:

<pre>{{ dump(craft.app.security.validateData('incorrect_value')) }}</pre>

I get this:

C:\craft\vendor\twig\twig\src\Extension\DebugExtension.php:61:string '' (length=0)

It returns empty string.

@brandonkelly
Copy link
Member

Looks like this was broken for both PHP and Twig. Just fixed for tomorrow’s release. Thanks for reporting!

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