1. 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

Discussion in 'Resolved Bug Reports' started by thedude, Aug 21, 2015.

  1. thedude

    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: Aug 21, 2015
  2. Mike

    Mike XenForo Developer Staff Member

    This is fixed now, thanks.
     

Share This Page