3th try .....
On Sun, November 12, 2006 1:15 pm, Ralf Hildebrandt wrote:
> * Marc Groot Koerkamp <marc@xxxxxxxxxxxxxxxx>:
>
>
>> Forget the first patch. You will need this patch.
>> Instead of a break 2 I needed a break 3 call ....
>>
>>
>> I need more coffee.
>>
>
> Applied.
>
>
> I get:
>
>
> File to patch: ./squirrelmail-1.4.8/class/mime/Message.class.php
> patching file ./squirrelmail-1.4.8/class/mime/Message.class.php patch
> unexpectedly ends in middle of line Hunk #3 succeeded at 1068 with fuzz 1.
>
After looking at the function again I think my change still has bugs. I
need to learn to write code which is fault less from scratch .... (it's
difficult when you cannot test ;) )
Anyway, attached is a patch and below I also give you the complete
parseQuote function if patching doesn't work. Yoy can then simply replace
the parseQuote function with below one.
Regards,
Marc Groot Koerkamp
/**
* 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 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;
if ($iPos && $read{$iPos -1} != '\\') {
$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;
$bEscaped = false;
} else {
$i = $j;
break 3;
}
break;
default:
if ($bEscaped) {
$bEscaped = false;
}
$s .= $cChar;
break;
}
}
}
++$iPos;
if ($iPos > strlen($read)) {
break;
}
}
return $s;
}
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 12 Nov 2006 18:56:38 -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,37 @@
$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;
+ $bEscaped = false;
+ } else {
+ $i = $j;
+ break 3;
+ }
+ break;
+ default:
+ if ($bEscaped) {
+ $bEscaped = false;
+ }
+ $s .= $cChar;
+ break;
+ }
+ }
}
++$iPos;
if ($iPos > strlen($read)) {
@@ -1030,7 +1072,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