Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112333 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 72941 invoked from network); 1 Dec 2020 17:50:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Dec 2020 17:50:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9602A1804C9 for ; Tue, 1 Dec 2020 09:18:20 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from dd46610.kasserver.com (dd46610.kasserver.com [85.13.163.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 1 Dec 2020 09:18:19 -0800 (PST) Received: from [192.168.178.23] (dynamic-077-008-005-013.77.8.pool.telefonica.de [77.8.5.13]) by dd46610.kasserver.com (Postfix) with ESMTPSA id 3A3DD5F80050 for ; Tue, 1 Dec 2020 18:18:18 +0100 (CET) To: PHP internals Organization: Aimeos GmbH Message-ID: Date: Tue, 1 Dec 2020 18:18:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: PHP 8 is_file/is_dir input handling From: norbert@aimeos.com (Aimeos | Norbert Sendetzky) Hi internals PHP 8 is stricter in checking input data then PHP 7. This is good but has some side effects for is_file(), is_dir() and similar functions when invalid paths are passed for checking. 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. My suggestion for simpler client side code would be to return FALSE in this situation for PHP 8 too instead of throwing the ValueException. Otherwise, it's not possible to use is_file() and related functions without adding a try/catch block around in any web application. Best, Norbert