Bug #80933 [NEW]: When flag DROP_NEW_LINE is enabled, line read stops at null char
From: gabrielpl at gmail dot com
Operating system: Windows
PHP version: 8.0.3
Package: SPL related
Bug Type: Bug
Bug description:When flag DROP_NEW_LINE is enabled, line read stops at null char
Description:
------------
When the flag DROP_NEW_LINE is enabled in SplFileObject classes, reading
a line (e.g. fgets()) stops at null char.
When the flag is disabled, the read operation works as intended.
Test script:
---------------
<?php
// string with a NULL char
$line = "Lorem ipsum \0 dolor sit amet";
$temp = new SplTempFileObject();
$temp->fwrite($line);
$temp->rewind();
$read = $temp->fgets();
echo 'SplFileObject::DROP_NEW_LINE flag -> disabled' . PHP_EOL;
var_dump(strcmp($line, $read), $read);
$temp->rewind();
$temp->setFlags(SplFileObject::DROP_NEW_LINE);
$read = $temp->fgets();
echo PHP_EOL . 'SplFileObject::DROP_NEW_LINE flag -> enabled' .
PHP_EOL;
var_dump(strcmp($line, $read), $read);
--
Edit bug report at https://bugs.php.net/bug.php?id=80933&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80933&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80933&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80933&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80933&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80933&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80933&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80933&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80933&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80933&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80933&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80933&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80933&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80933&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80933&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80933&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80933&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80933&r=mysqlcfg
Thread (7 messages)
- gabrielpl at gmail dot com
- requinix@php.netBug #80933 [Opn->Ver]: When flag DROP_NEW_LINE is enabled, line read stops at null char
- cmb@php.netBug #80933 [Ver]: When flag DROP_NEW_LINE is enabled, line read stops at null char
- cmb@php.netBug #80933 [PATCH]: When flag DROP_NEW_LINE is enabled, line read stops at null char
- gabrielpl at gmail dot comBug #80933 [Ver]: When flag DROP_NEW_LINE is enabled, line read stops at null char
- cmb@php.netBug #80933 [Ver]: SplFileObject::DROP_NEW_LINE is broken for NUL and CR
- git@php.netBug #80933 [Ver->Csd]: SplFileObject::DROP_NEW_LINE is broken for NUL and CR