php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45216 SplFileObject::fgetss is not accepting 0 as max_line_len
Submitted: 2008-06-09 15:52 UTC Modified: 2008-06-18 10:07 UTC
From: perrick at noparking dot net Assigned: colder (profile)
Status: Closed Package: SPL related
PHP Version: 5.3CVS-2008-06-09 (snap) OS: mac os x
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: perrick at noparking dot net
New email:
PHP Version: OS:

 

 [2008-06-09 15:52 UTC] perrick at noparking dot net
Description:
------------
SplFileObject::fgetss($allowable_tags = NULL) doesn't work at all.

The underlying fgetss that's called in the object needs a length :
"string fgetss ( resource $handle [, int $length [, string $allowable_tags ]] )"

A test is available on testfest.php.net :

http://testfest.php.net/index.php?do=details&task_id=126

Reproduce code:
---------------
$file = dirname(__FILE__) . '/foo.html';
file_put_contents($file, 'text 0<div class="tested">text 1</div>');
$handle = fopen($file, 'r');

$object = new SplFileObject($file);
var_dump($object->fgetss());
var_dump(fgetss($handle));

Expected result:
----------------
string(12) "text 0text 1"
string(12) "text 0text 1"


Actual result:
--------------
Warning: fgetss(): Length parameter must be greater than 0 in /Users/perrick/Desktop/testfest/spl_fileobject_fgetss_basic.php on line 7

string(12) "text 0text 1"


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-18 10:07 UTC] colder@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

As the title change says, the problem was not the mapping, but rather that fgetss was fed with the max_line_len which could be 0, and fgetss choke on 0. 

Now if the max_line_len is <= 0, it defaults to 1024.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 11 19:01:28 2024 UTC