• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed Input filtering bug with boolean values


Well-known member
The following code returns false instead of true
$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:
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: