Edit report at https://bugs.php.net/bug.php?id=64166&edit=1

 ID:                 64166
 Updated by:         s...@php.net
 Reported by:        slusarz at curecanti dot org
 Summary:            quoted-printable-encode stream filter incorrectly
                     discarding whitespace
 Status:             Open
 Type:               Bug
 Package:            Streams related
 Operating System:   Linux
 PHP Version:        5.4.11
 Block user comment: N
 Private report:     N

 New Comment:

The patch seems to have problems with split writes, see my comments there.


Previous Comments:
------------------------------------------------------------------------
[2013-02-07 19:41:22] slusarz at curecanti dot org

Added pull request with fix that seems to work (w/unit test):

https://github.com/php/php-src/pull/272

------------------------------------------------------------------------
[2013-02-07 01:14:58] slusarz at curecanti dot org

Just kidding... apparently there's a difference between "filter" and "stream 
filter".  Sorry for the noise.

------------------------------------------------------------------------
[2013-02-07 01:14:09] slusarz at curecanti dot org

This is actually a stream *filter* issue, so put in filter queue.

------------------------------------------------------------------------
[2013-02-07 00:49:44] slusarz at curecanti dot org

Description:
------------
The QP stream filter is incorrectly discarding whitespace at the end of the 
lines.  The quoted_printable_encode() method does not have this issue.

This is troublesome when attempting to save flowed text/plain data, as it 
causes the data to lose its flowed formatting.  (I realize that RFC 3676 says 
flowed text SHOULD NOT be encoded in QP, but this is an (arguably) outdated 
policy restriction and not a technical restriction).

Test script:
---------------
<?php

$data = "FIRST \r\nSECOND";

$fp = fopen('php://temp', 'w+');
stream_filter_append($fp, 'convert.quoted-printable-encode', 
STREAM_FILTER_WRITE, array(
    'line-length' => 76
));
fwrite($fp, $data);
rewind($fp);

print quoted_printable_encode($data) . "\n";
print stream_get_contents($fp);

Expected result:
----------------
FIRST=20
SECOND
FIRST=20
SECOND

Actual result:
--------------
FIRST=20
SECOND
FIRST
SECOND


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64166&edit=1

Reply via email to