Bug #1897 Updated: quoted_printable_decode doesn't work properly.
| From: | Bug Database | Date: | Thu, 29 Jul 1999 00:25:22 +0000 |
| Subject: | Bug #1897 Updated: quoted_printable_decode doesn't work properly. | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-9301@lists.php.net to get a copy of this message | ||
ID: 1897
User Update by: bfranklin@dct.com
Status: Open
Bug Type: Misbehaving function
Description: quoted_printable_decode doesn't work properly.
quoted_printable_decode doesn't properly handle soft line breaks or encoded data that has been
padded with whitespace at the end of a line.
The first patch I gave has some major flaws in it. Here is a much improved one:
--- functions/quot_print.c.orig Wed Jun 16 06:34:22 1999
+++ functions/quot_print.c Wed Jul 28 19:15:29 1999
@@ -94,11 +94,23 @@
+ _php3_hex2int((int)str[i+2]);
i += 3;
}
- else if ( str[i] == 13 )
- {
- i++;
- }
- else
+ else if ( str[i] == '=' )
+ {
+ if( str[i+1] == 10 || str[i+1] == 13 )
+ i+=2;
+ else if( str[i+1] == 13 && str[i+2] == 10 )
+ i+=3;
+ else
+ str[j++] = str[i++]; /* prevent infinite loop on invalid input */
+ }
+ else if ( (str[i] == 9 || str[i] == 32) && str[i+1] == 13 )
+ {
+ while ( (str[j] == 9 || str[j] == 32) && j>0 )
+ j--;
+ j++; i++;
+ str[j++] = str[i++];
+ }
+ else
{
str[j++] = str[i++];
}
Full Bug description available at: http://bugs.php.net/?id=1897