فهرست منبع

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
     }
 }
 
-?>
+?>