From 2ddf00ae09d3d3b7c06fb721e1477bd144febaa7 Mon Sep 17 00:00:00 2001 From: stekkel Date: Sat, 28 Jun 2003 20:17:17 +0000 Subject: [PATCH 1/1] Added rfc2184 support in order to handle: Multilined parameters Parameters with charset and language information. Only problem: I don't have a single message with rfc2184 headers so I couldn't test it. Probably it works okay because the RFC wasn't that complicated. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@5143 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- class/mime/Rfc822Header.class.php | 34 ++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/class/mime/Rfc822Header.class.php b/class/mime/Rfc822Header.class.php index d4d36604..bcacda49 100644 --- a/class/mime/Rfc822Header.class.php +++ b/class/mime/Rfc822Header.class.php @@ -502,6 +502,38 @@ class Rfc822Header { } $this->content_type = $content_type; } + + /* RFC2184 */ + function processParameters($aParameters) { + $aResults = array(); + $aCharset = array(); + // handle multiline parameters + foreach($aParameters as $key => $value) { + if ($iPos = strpos($key,'*')) { + $sKey = substr($key,0,$iPos); + if (!isset($aResults[$sKey])) { + $aResults[$sKey] = $value; + if (substr($key,-1) == '*') { // parameter contains language/charset info + $aCharset[] = $sKey; + } + } else { + $aResults[$sKey] .= $value; + } + } + } + foreach ($aCharset as $key) { + $value = $aResults[$key]; + // extract the charset & language + $charset = substr($value,0,strpos($value,"'")); + $value = substr($value,strlen($charset)+1); + $language = substr($value,0,strpos($value,"'")); + $value = substr($value,strlen($charset)+1); + // FIX ME What's the status of charset decode with language information ???? + $value = charset_decode($charset,$value); + $aResults[$key] = $value; + } + return $aResults; + } function parseProperties($value) { $propArray = explode(';', $value); @@ -518,7 +550,7 @@ class Rfc822Header { $propResultArray[$key] = $val; } } - return $propResultArray; + return $this->processParameters($propResultArray); } function parseDisposition($value) { -- 2.25.1