Re: Can't decode MIME structure (2ed Try)

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

 



Forget the first patch. You will need this patch.
Instead of a break 2 I needed a break 3 call ....

I need more coffee.

Marc.



On Sat, November 11, 2006 8:30 pm, Marc Groot Koerkamp wrote:
> On Sat, November 11, 2006 11:41 am, Ralf Hildebrandt wrote:
>
>> * Marc Groot Koerkamp <marc@xxxxxxxxxxxxxxxx>:
>>
>>
>>
>>> It took me some time to refresh my bodystructure knowledge but after
>>> looking at the code again I know why you are getting an error. The
>>> "Colb
>>>
>>>>> \\Helga.Colbatz\\" part is causing an error.
>>>>>
>>>
>>
>> It is. I verified this by editing out the offending parts. From the
>> original mail (that thing is a Cc: header):
>>
>> CC: "Colb >> \"Helga.Colbatz\"" <helga.colbatz@xxxxxxxxxxx>
>> does expose the error
>>
>> CC: "Colb >> \"Helga.Colbatz" <helga.colbatz@xxxxxxxxxxx>
>> does work just fine.
>
> Good, that's what I thought.
>
>>
>> You're the best. If you want the original mail, I stil have it flying
>> around here.
>>
>
> Nope, I don't need it. What I do need is you testing the attached patch
> ;)
> The patch is against 1.4.8 stable. I cannot test it myself because
> Cyrus-Imap is returning strings with escape characters as literal which
> means that it cannot fail because in that case i don't have to check for
> escape characters.
>
> So if you can test the patch and report back if it works then I commit it
>  to stable and devel.
>
> Regards,
>
>
> Marc Groot
> Koerkamp.----------------------------------------------------------------
> ---------
> 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: 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	11 Nov 2006 19:32:27 -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,33 @@
                 $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;
+                for ($j=$iPosStart,$iCnt=count($read);$j<$iCbt;++$j) {
+                    $cChar = $read{$j};
+                    switch ($cChar) {
+                        case '\\':
+                            $bEscaped = !$bEscaped;
+                            $s .= $cChar;
+                            break;
+                         case '"':
+                            if ($bEscaped) {
+                                $s .= $cChar;
+                            } else {
+                                $i = $j;
+                                break 3;
+                            }
+                            break;
+                         default:
+                            $s .= $cChar;
+                            break;
+                    }
+                }
             }
             ++$iPos;
             if ($iPos > strlen($read)) {
@@ -1030,7 +1068,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