quoted-printable-encode stream filter incorrectly discarding whitespace

Bug #64166 quoted-printable-encode stream filter incorrectly discarding whitespace
Submitted: 2013-02-07 00:49 UTC Modified: 2013-02-25 02:28 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: slusarz at curecanti dot org Assigned:
Status: Closed Package: Streams related
PHP Version: 5.4.11 OS: Linux
Private report: No CVE-ID: None

 [2013-02-07 00:49 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports

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

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

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

-Package: Streams related +Package: Filter related

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

-Package: Filter related +Package: Streams related

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

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

 [2013-02-17 09:13 UTC] stas@php.net

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

 [2013-02-25 02:28 UTC] slusarz at curecanti dot org

Updated pull request with new commit that should take care of all concerns.  Also implemented a more complete unit test.

 [2013-06-16 23:41 UTC] stas@php.net

-Status: Open +Status: Closed