Edit report at https://bugs.php.net/bug.php?id=80933&edit=1
ID: 80933
Updated by: git@php.net
Reported by: gabrielpl at gmail dot com
Summary: SplFileObject::DROP_NEW_LINE is broken for NUL and
CR
-Status: Verified
+Status: Closed
Type: Bug
Package: SPL related
Operating System: Windows
PHP Version: 7.4
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of cmb69
Revision: https://github.com/php/php-src/commit/976e71a2fa239cd7336bdcc56fcd7639b2e4edfd
Log: Fix #80933: SplFileObject::DROP_NEW_LINE is broken for NUL and CR
Previous Comments:
------------------------------------------------------------------------
[2021-04-07 10:08:45] cmb@php.net
Indeed, you're right! We need to use php_stream_locate_eol()
instead of (php_)strcspn() to properly detect the line endings.
------------------------------------------------------------------------
[2021-04-07 00:34:40] gabrielpl at gmail dot com
Looking the original source and the patch #80933...
I think the following string will not pass the test:
// string with a carriage return char
$line = "Lorem ipsum \r dolor sit amet";
Could someone confirm?
------------------------------------------------------------------------
[2021-04-05 16:35:19] cmb@php.net
The following pull request has been associated:
Patch Name: Fix #80933: SplFileObject::fgets() stops at NUL byte for DROP_NEW_LINE
On GitHub: https://github.com/php/php-src/pull/6836
Patch: https://github.com/php/php-src/pull/6836.patch
------------------------------------------------------------------------
[2021-04-05 15:39:38] cmb@php.net
Good catch, @requinix!
------------------------------------------------------------------------
[2021-04-04 07:04:28] requinix@php.net
Simple naive use of strcspn.
https://github.com/php/php-src/blob/PHP-8.0.3/ext/spl/spl_directory.c#L1891
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=80933
--
Edit this bug report at https://bugs.php.net/bug.php?id=80933&edit=1