瀏覽代碼

X- style headers are optional and don't us comments like other headers. So
we shouldn't parse them. (RFC 2822 Section 3.6.8)

indiri69 23 年之前
父節點
當前提交
9116ca70bc
共有 1 個文件被更改,包括 27 次插入25 次删除
  1. 27 25
      class/mime.class.php

+ 27 - 25
class/mime.class.php

@@ -43,31 +43,33 @@ class rfc822_header
     function parseHeader($hdr)
     {
         if (is_array($hdr))
-	{
-	   $hdr = implode('',$hdr);
-	}
+        {
+            $hdr = implode('',$hdr);
+        }
         /* first we unfold the header */
-	$hdr = trim(str_replace(array("\r\n\t","\r\n "),array('',''),$hdr));
-	/* 
-	 * now we can make a new header array with each element representing 
-	 * a headerline
-	 */
-	$hdr = explode("\r\n" , $hdr);  
-	foreach ($hdr as $line)
-	{
-	   $pos = strpos($line,':');
-	   if ($pos > 0)
-	   {
-	      $field = substr($line,0,$pos);
-	      $value = trim(substr($line,$pos+1));
-	      $value = $this->stripComments($value);
-	      $this->parseField($field,$value);
-	   }
-	}
-	if ($this->content_type == '')
-	{
-	   $this->parseContentType('text/plain; charset=us-ascii');
-	}
+        $hdr = trim(str_replace(array("\r\n\t","\r\n "),array('',''),$hdr));
+        /* 
+         * now we can make a new header array with each element representing 
+         * a headerline
+         */
+        $hdr = explode("\r\n" , $hdr);  
+        foreach ($hdr as $line)
+        {
+            $pos = strpos($line,':');
+            if ($pos > 0)
+            {
+                $field = substr($line,0,$pos);
+                $value = trim(substr($line,$pos+1));
+                if(!preg_match('/^X.*/',$value)) {
+                    $value = $this->stripComments($value);
+                }
+                $this->parseField($field,$value);
+            }
+        }
+        if ($this->content_type == '')
+        {
+            $this->parseContentType('text/plain; charset=us-ascii');
+        }
     }
     
     function stripComments($value)
@@ -1698,4 +1700,4 @@ class content_type
     }
 }
 
-?>
+?>