Logo Search packages:      
Sourcecode: d-push version File versions  Download package

Mail_mimeDecode::_decodeHeader ( input )

Given a header, this function will decode it according to RFC2047. Probably not *exactly* conformant, but it does pass all the given examples (in RFC2047).

stringInput header value to decode
string Decoded header value private

Definition at line 572 of file mimeDecode.php.

References _fromCharset().

Referenced by _parseHeaders().

        // Remove white space between encoded-words
        $input = preg_replace('/(=\?[^?]+\?(q|b)\?[^?]*\?=)(\s)+=\?/i', '\1=?', $input);

        // For each encoded-word...
        while (preg_match('/(=\?([^?]+)\?(q|b)\?([^?]*)\?=)/i', $input, $matches)) {

            $encoded  = $matches[1];
            $charset  = $matches[2];
            $encoding = $matches[3];
            $text     = $matches[4];

            switch (strtolower($encoding)) {
                case 'b':
                    $text = base64_decode($text);

                case 'q':
                    $text = str_replace('_', ' ', $text);
                    preg_match_all('/=([a-f0-9]{2})/i', $text, $matches);
                    foreach($matches[1] as $value)
                        $text = str_replace('='.$value, chr(hexdec($value)), $text);

            $input = str_replace($encoded, $this->_fromCharset($charset, $text), $input);

        return $input;

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index