Re: Can't decode MIME structure (3th Try)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Ralf,

On Sun, November 12, 2006 8:11 pm, Ralf Hildebrandt wrote:
> * Marc Groot Koerkamp <marc@xxxxxxxxxxxxxxxx>:
>
> I patched, yet I still get an error.
> Could you send the function parseQuote as attachment?
> Also,
> a) where do I replace it? b) do I have to revert the patch then?
>

This time I managed to test your bodystructure. The attached patch should
work. If the patch doesn't work then replace the file
class/mime/Message.class.php with the one in the zip file.

Regards,

Marc Groot Koerkamp

Attachment: Message.class.php.gz
Description: GNU Zip compressed data

Index: class/mime/Message.class.php
===================================================================
RCS file: /cvsroot/squirrelmail/squirrelmail/class/mime/Message.class.php,v
retrieving revision 1.17.2.14
diff -u -F^f -r1.17.2.14 Message.class.php
--- class/mime/Message.class.php	3 Feb 2006 22:27:46 -0000	1.17.2.14
+++ class/mime/Message.class.php	13 Nov 2006 20:16:45 -0000
@@ -633,14 +633,25 @@
     }
 
     /**
+     * function parseQuote
+     *
+     * This extract the string value from a quoted string. After the end-quote
+     * character is found it returns the string. The offset $i when calling
+     * this function points to the first double quote. At the end it points to
+     * The ending quote. This function takes care of escaped double quotes.
+     * "some \"string\""
+     * ^               ^
+     * initial $i      end position $i
+     *
      * @param string $read
-     * @param integer $i
-     * @return string
-     * @todo document me
+     * @param integer $i offset in $read
+     * @return string string inbetween the double quotes
+     * @author Marc Groot Koerkamp
      */
     function parseQuote($read, &$i) {
         $s = '';
         $iPos = ++$i;
+        $iPosStart = $iPos;
         while (true) {
             $iPos = strpos($read,'"',$iPos);
             if (!$iPos) break;
@@ -648,6 +659,38 @@
                 $s = substr($read,$i,($iPos-$i));
                 $i = $iPos;
                 break;
+            } else if ($iPos > 1 && $read{$iPos -1} == '\\' && $read{$iPos-2} == '\\') {
+                // This is an unique situation where the fast detection of the string
+                // fails. If the quote string ends with \\ then we need to iterate
+                // through the entire string to make sure we detect the unexcaped
+                // double quotes correctly.
+                $s = '';
+                $bEscaped = false;
+                $k = 0;
+                 for ($j=$iPosStart,$iCnt=strlen($read);$j<$iCnt;++$j) {
+                    $cChar = $read{$j};
+                    switch ($cChar) {
+                        case '\\':
+                           $bEscaped = !$bEscaped;
+                            $s .= $cChar;
+                            break;
+                         case '"':
+                            if ($bEscaped) {
+                                $s .= $cChar;
+                                $bEscaped = false;
+                            } else {
+                                $i = $j;
+                                break 3;
+                            }
+                            break;
+                         default:
+                            if ($bEscaped) {
+                               $bEscaped = false;
+                            }
+                            $s .= $cChar;
+                            break;
+                    }
+                }
             }
             ++$iPos;
             if ($iPos > strlen($read)) {
@@ -1030,7 +1073,7 @@
         $attachment->mime_header = $mime_header;
         $this->entities[]=$attachment;
     }
-    
+
     /**
      * Delete all attachments from this object from disk.
      * @since 1.4.6
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
--
squirrelmail-users mailing list
Posting Guidelines: http://www.squirrelmail.org/wiki/MailingListPostingGuidelines
List Address: squirrelmail-users@xxxxxxxxxxxxxxxxxxxxx
List Archives: http://news.gmane.org/thread.php?group=gmane.mail.squirrelmail.user
List Archives:  http://sourceforge.net/mailarchive/forum.php?forum_id=2995
List Info: https://lists.sourceforge.net/lists/listinfo/squirrelmail-users

[Index of Archives]     [Video For Linux]     [Yosemite News]     [Yosemite Photos]     [gtk]     [KDE]     [Cyrus SASL]     [Gimp on Windows]     [Steve's Art]     [Webcams]

  Powered by Linux