fix for language argument and add language class.
[squirrelmail.git] / class / mime.class
index 39654fe80a716b12a9800f5aad28c6df402b8f29..4f06c29e132ddd7bc9afd2751385392851feb5b2 100644 (file)
@@ -332,6 +332,7 @@ class message {
                    $i++;
                    $arg_a[] = $msg->parseDisposition($read,&$i);
                 } else {
+                   $i++;
                    $arg_a[] = $msg->parseLanguage($read,&$i);
                 }
                 $arg_no++;    
@@ -339,8 +340,10 @@ class message {
               case 10:
                 if ($arg_a[0] == 'text' ||
                       ($arg_a[0] == 'message' && $arg_a[1] == 'rfc822')) {
+                   $i++;                      
                    $arg_a[] = $msg->parseLanguage($read,&$i);
                 }  else {
+                   $msg->parseParenthesis($read,&$i);
                    $arg_a[] = ''; /* not yet desribed in rfc2060 */
                 }
                 $arg_no++;
@@ -689,24 +692,34 @@ class message {
     
     function parseLanguage($read,&$i) {
         /* no idea how to process this one without examples */
-        $arg = '';
+        $arg_a = array();
         while ($read{$i} != ')') {
           switch ($read{$i}) {
             case '"':
-              $arg = $this->parseQuote($read,&$i);
+              $arg_a[] = $this->parseQuote($read,&$i);
               break;
             case '{': 
-              $arg = $this->parseLiteral($read,&$i);
+              $arg_a[] = $this->parseLiteral($read,&$i);
               break;
             case '(':
-              $arg = $this->parseProperties($read,&$i);
+              $arg_a[] = $this->parseProperties($read,&$i);
               break;
             default:
               break;
           }
           $i++;
         }
-        return $arg;;
+       if (isset($arg_a[0])) {
+          $lang = new language($arg_a[0]);
+          if (isset($arg_a[1])) {
+             $lang->properties = $arg_a[1];
+          }
+       }
+       if (is_object($lang)) { 
+          return $lang;
+       } else {
+          return '';
+        }
     }
     
     function parseParenthesis($read,&$i) {
@@ -856,4 +869,11 @@ class disposition {
   }
 }
 
+class language {
+  function language($name) {
+     $this->name = $name;
+     $this->properties = array();
+  }
+}
+
 ?>