webinarium / DataTablesBundle

Symfony bundle for DataTables plugin.
MIT License
16 stars 9 forks source link

Invalid Boolean parsing #12

Closed laurentmuller closed 5 years ago

laurentmuller commented 5 years ago

When parsing Parameters to create a DataTableQuery, the values (like 'searchable' or 'orderable') are cast to a boolean with code like:

(bool) $column['orderable']

But the parameter value is the literal 'true' or 'false' and when cast, it returns always true because a non-empty string to a bool value, returns always true.

A bug fix is to test the literal value with code like:

'true' === $column['orderable']

or

filter_var($column['orderable'], FILTER_VALIDATE_BOOLEAN)

or modify the validation with:

->setAllowedTypes('orderable', 'boolean')

See: PHP Documentation

Tested with Symfony v3.4.24 and PHP v7.2.14.

webinarium commented 5 years ago

True, thank you for the finding. I have updated the UnitTests so they find this issue now, then fixed the bug and released new version 2.3.2. Please upgrade.