Mantis - Quercus
Viewing Issue Advanced Details
1115 minor always 05-16-06 15:26 05-16-06 18:52
koreth  
ferg  
normal  
closed 3.0.20  
fixed  
none    
none 3.0.20  
0001115: fgets() on socket strips trailing cr/lf
PHP code:

<?php
$sock = @fsockopen("localhost", 2222);
$line = fgets($sock);
print "[" . $line . "]";
?>

I use "nc -l -p 2222" to listen on port 2222, then execute this page (piped through "od -xc" so I can see the exact output).

With Zend PHP, if I type "foo" into nc, I get "[foo\n]" as output. With Quercus, I get "[foo]". Trailing carriage returns are stripped too.

This doesn't seem to happen on files; if I fopen() a file, fgets() returns the trailing newline on both Quercus and Zend PHP.

Notes
(0001143)
ferg   
05-16-06 18:52   
php/1m0b