php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3110 quoted_printable_decode _still_ doesn't work properly.
Submitted: 2000-01-05 15:56 UTC Modified: 2005-03-30 09:02 UTC
From: bfranklin at dct dot com Assigned:
Status: Wont fix Package: Misbehaving function
PHP Version: 3.0.13 OS: Solaris 2.7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: bfranklin at dct dot com
New email:
PHP Version: OS:

 

 [2000-01-05 15:56 UTC] bfranklin at dct dot com
quoted_printable_decode still doesn't handle 'soft' line breaks or padding correctly.  If you want to see it fail, try running it on the encoded string given in RFC-1521 section 5.1 rule #5.  To save you the trouble this is what code to do that would look like.

<?
# the extra spaces and tabs after the '='s where added by
# me to demonstrate that they aren't handled properly either
# see rule 3 in the same section of the RFC
$string = "Now's the time =   \r\n";
$string .= "for all folk to come=\t \t \r\n";
$string .= " to the aid of their country.";
echo quoted_printable_decode($string);
?>

The = characters in the out put are not supposed to be there.

To save you some time, here is the patch I use to fix this problem.  It's a patch against 3.0.11.  But this function hasn't changed much (if at all) since then.

--- php-3.0.11/functions/quot_print.c.orig  Wed Jun 16 06:34:22 1999
+++ php-3.0.11/functions/quot_print.c Wed Jul 28 12:03:19 1999
@@ -94,11 +94,21 @@
                   + _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 if ( (str[i] == 9 || str[i] == 32) && str[i+1] == 13 )
+      {
+              while ( str[j] == 9 || str[j] == 32 )
+                      j--;
+              j++;
+              str[j++] = str[i++];
+      }
+      else
      {
        str[j++] = str[i++];
      }

I've also checked 4.0b3 and the bug exists there as well.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-30 09:02 UTC] sniper@php.net
We are sorry, but we can not support PHP 3 related problems anymore.
Momentum is gathering for PHP 5, and we think supporting PHP 3 will
lead to a waste of resources which we want to put into getting PHP 5
ready. Of course PHP 4 will continue to be supported for the
forseeable future.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC