#24727 [Com]: Net::NNTP getBody() breaks binary data with trim()
| From: | developer at heino dot gehlsen dot dk | Date: | Mon, 21 Jul 2003 14:41:50 +0000 |
| Subject: | #24727 [Com]: Net::NNTP getBody() breaks binary data with trim() | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-18490@lists.php.net to get a copy of this message | ||
ID: 24727
Comment by: developer at heino dot gehlsen dot dk
Reported By: meebey@php.net
Status: Open
Bug Type: PEAR related
Operating System: Debian
PHP Version: Irrelevant
New Comment:
using str_replace() on the whole string would make some unwanted
overhead!
using rtrim() would do the job
-------------------------------------------------
- $line = trim(fgets($this->fp, 256));
+ $line = rtrim(fgets($this->fp, 256), "\r\n");
-------------------------------------------------
Tthe code will still not be binary safe, since rfc977 handles
$line[0]=='.' by doubling the '.' to '..'
Previous Comments:
------------------------------------------------------------------------
[2003-07-20 10:57:28] meebey@php.net
Description:
------------
getBody() of the NNTP class does a trim() for each time it reads data
from the server, this breaks binary data.
It should just cut the \r\n with a str_replace or something similiar,
the trim() function removes chars which can be part of binary data.
Here the patch:
--- NNTP.php 2003-07-20 17:55:30.000000000 +0200
+++ NNTPpatched.php 2003-07-20 17:55:52.000000000 +0200
@@ -377,7 +377,7 @@
$body = null;
while (!feof($this->fp)) {
- $line = trim(fgets($this->fp, 256));
+ $line = str_replace("\r\n", '', fgets($this->fp, 256));
if ($line == '.') {
break;
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24727&edit=1