thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/PercentEncoder.php
public function normalize($string) {
        if ($string == '') return '';
        $parts = explode('%', $string);
        $ret = array_shift($parts);
        foreach ($parts as $part) {
            $length = strlen($part);
            if ($length < 2) {
                $ret .= '%25' . $part;
                continue;
            }
            $encoding = substr($part, 0, 2);
            $text     = substr($part, 2);
            if (!ctype_xdigit($encoding)) {
                $ret .= '%25' . $part;
                continue;
            }
            $int = hexdec($encoding);
            if (isset($this->preserve[$int])) {
                $ret .= chr($int) . $text;
                continue;
            }
            $encoding = strtoupper($encoding);
            $ret .= '%' . $encoding . $text;
        }
        return $ret;
    }
public function normalize($string) {
        if ($string == '') return '';
        $parts = explode('%', $string);
        $ret = array_shift($parts);
        foreach ($parts as $part) {
            $length = strlen($part);
            if ($length < 2) {
                $ret .= '%25' . $part;
                continue;
            }
            $encoding = substr($part, 0, 2);
            $text     = substr($part, 2);
            if (!ctype_xdigit($encoding)) {
                $ret .= '%25' . $part;
                continue;
            }
            $int = hexdec($encoding);
            if (isset($this->preserve[$int])) {
                $ret .= chr($int) . $text;
                continue;
            }
            $encoding = strtoupper($encoding);
            $ret .= '%' . $encoding . $text;
        }
        return $ret;
    }
public function normalize ( $ string ) { if ( $ string == '' ) return '' ; $ parts = explode ( '%' , $ string ) ; $ ret = array_shift ( $ parts ) ; foreach ( $ parts as $ part ) { $ length = strlen ( $ part ) ; if ( $ length < 2 ) { $ ret .= '%25' . $ part ; continue ; } $ encoding = substr ( $ part , 0 , 2 ) ; $ text = substr ( $ part , 2 ) ; if ( ! ctype_xdigit ( $ encoding ) ) { $ ret .= '%25' . $ part ; continue ; } $ int = hexdec ( $ encoding ) ; if ( isset ( $ this -> preserve [ $ int ] ) ) { $ ret .= chr ( $ int ) . $ text ; continue ; } $ encoding = strtoupper ( $ encoding ) ; $ ret .= '%' . $ encoding . $ text ; } return $ ret ; }
Fix up percent-encoding by decoding unreserved characters and normalizing.
@warning This function is affected by $preserve, even though the
usual desired behavior is for this not to preserve those
characters. Be careful when reusing instances of PercentEncoder!
@param $string String to normalize
Fix up percent - encoding by decoding unreserved characters and normalizing .