public static function filter($value)
    {
        $value = (string) $value;
        $length = strlen($value);
        $string = '';

        for ($i = 0; $i < $length; $i += 1) {
            $ascii = ord($value[$i]);

            // Detect continuation sequences
            if ($ascii === 13) {
                $lf = ord($value[$i + 1]);
                $ws = ord($value[$i + 2]);

                if ($lf === 10 && in_array($ws, [9, 32], true)) {
                    $string .= $value[$i] . $value[$i + 1];
                    $i += 1;
                }

                continue;
            }

            // Non-visible, non-whitespace characters
            // 9 === horizontal tab
            // 32-126, 128-254 === visible
            // 127 === DEL
            // 255 === null byte
            if (($ascii < 32 && $ascii !== 9) || $ascii === 127 || $ascii > 254) {
                continue;
            }

            $string .= $value[$i];
        }

        return $string;
    }
public static function filter($value)
    {
        $value = (string) $value;
        $length = strlen($value);
        $string = '';

        for ($i = 0; $i < $length; $i += 1) {
            $ascii = ord($value[$i]);

            // Detect continuation sequences
            if ($ascii === 13) {
                $lf = ord($value[$i + 1]);
                $ws = ord($value[$i + 2]);

                if ($lf === 10 && in_array($ws, [9, 32], true)) {
                    $string .= $value[$i] . $value[$i + 1];
                    $i += 1;
                }

                continue;
            }

            // Non-visible, non-whitespace characters
            // 9 === horizontal tab
            // 32-126, 128-254 === visible
            // 127 === DEL
            // 255 === null byte
            if (($ascii < 32 && $ascii !== 9) || $ascii === 127 || $ascii > 254) {
                continue;
            }

            $string .= $value[$i];
        }

        return $string;
    }
public static function filter ( $ value ) { $ value = ( string ) $ value ; $ length = strlen ( $ value ) ; $ string = '' ; for ( $ i = 0 ; $ i < $ length ; $ i += 1 ) { $ ascii = ord ( $ value [ $ i ] ) ; // Detect continuation sequences if ( $ ascii === 13 ) { $ lf = ord ( $ value [ $ i + 1 ] ) ; $ ws = ord ( $ value [ $ i + 2 ] ) ; if ( $ lf === 10 && in_array ( $ ws , [ 9 , 32 ] , true ) ) { $ string .= $ value [ $ i ] . $ value [ $ i + 1 ] ; $ i += 1 ; } continue ; } // Non-visible, non-whitespace characters // 9 === horizontal tab // 32-126, 128-254 === visible // 127 === DEL // 255 === null byte if ( ( $ ascii < 32 && $ ascii !== 9 ) || $ ascii === 127 || $ ascii > 254 ) { continue ; } $ string .= $ value [ $ i ] ; } return $ string ; }
Method to remove invalid CRLF injection from header value.

Follows RFC-7230, only allows visible ASCII characters, spaces
and tabs in header value. every new line must only contains
a single CRLF and a space or tab after it.

@see http://en.wikipedia.org/wiki/HTTP_response_splitting
@see https://tools.ietf.org/html/rfc7230

@param   string $value The value to filter.

@return  string  Filtered value.
Method to remove invalid CRLF injection from header value .