Fixed Input filtering bug with boolean values

thedude

Well-known member
The following code returns false instead of true
Code:
$value = $this->_input->filterSingle('non_existent_variable', XenForo_Input::BOOLEAN, array('default' => true));

At the end of XenForo_Input::filterSingle, _doClean is called.

_doClean contains the following code:
Code:
case self::BOOLEAN:
if ($data === 'n' || $data == 'no' || $data === 'N')
{
    $data = false;
}

The loose comparison of $data to 'no' results in a true comparison (any non-empty string will loosely equal true), which will then set $data to equal false. Changing the comparison for 'no' to strict (===) fixes this issue.
 
Last edited:
Top Bottom