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

Mail_mimeDecode::_parseHeaderValue ( input )

Function to parse a header value, extract first part, and any secondary parts (after ;) This function is not as robust as it could be. Eg. header comments in the wrong place will probably break it.

Parameters:
stringHeader value to parse
Returns:
array Contains parsed result private

Definition at line 490 of file mimeDecode.php.

Referenced by _decode(), and _getXML_helper().

    {

        if (($pos = strpos($input, ';')) !== false) {

            $return['value'] = trim(substr($input, 0, $pos));
            $input = trim(substr($input, $pos+1));

            if (strlen($input) > 0) {

                // This splits on a semi-colon, if there's no preceeding backslash
                // Now works with quoted values; had to glue the \; breaks in PHP
                // the regex is already bordering on incomprehensible
                //$splitRegex = '/([^;\'"]*[\'"]([^\'"]*([^\'"]*)*)[\'"][^;\'"]*|([^;]+))(;|$)/';
                // simplyfied RegEx - Nokia Mail2 sends boundaries containing ' which break the above regex
                $splitRegex = '/([^;\'"]*[\'"]([^\'"]*)[\'"][^;\'"]*|([^;]+))(;|$)/';
                preg_match_all($splitRegex, $input, $matches);

                $parameters = array();
                for ($i=0; $i<count($matches[0]); $i++) {
                    $param = $matches[0][$i];
                    while (substr($param, -2) == '\;') {
                        $param .= $matches[0][++$i];
                    }
                    $parameters[] = $param;
                }

                for ($i = 0; $i < count($parameters); $i++) {
                    $param_name  = trim(substr($parameters[$i], 0, $pos = strpos($parameters[$i], '=')), "'\";\t\\ ");
                    $param_value = trim(str_replace('\;', ';', substr($parameters[$i], $pos + 1)), "'\";\t\\ ");
                    if (!empty($param_value[0]) && $param_value[0] == '"') {
                        $param_value = substr($param_value, 1, -1);
                    }
                    $return['other'][$param_name] = $param_value;
                    $return['other'][strtolower($param_name)] = $param_value;
                }
            }
        } else {
            $return['value'] = trim($input);
        }

        return $return;
    }

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index