Re: PHP 8 is_file/is_dir input handling

From: Date: Tue, 01 Dec 2020 17:35:01 +0000
Subject: Re: PHP 8 is_file/is_dir input handling
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-112335@lists.php.net to get a copy of this message
Am 01.12.20 um 18:24 schrieb Christoph M. Becker: >> In PHP 7, this returns FALSE: >> >> php -r 'var_dump(is_file("ab\0c"));' >> >> In PHP 8, the same code throws a ValueException. Problem is now that >> it's not possible to check upfront if the passed argument is a valid >> path to avoid the exception being thrown. > > This is only about the NUL byte in the filename. You can easily check > for that yourself. :) There may be other checks that will throw a ValueException. I'm not sure how it's implemented in detail because the filestat.c file doesn't thrown an exception at all: https://github.com/php/php-src/blob/1e9db80d7264911fa4089cb7e4b3dc7f97b19c6e/ext/standard/filestat.c Can you tell me how you would check for NULL bytes? Best, Norbert

« previous php.internals (#112335) next »