Repository navigation
Conversation
…me contains a NUL byte. As of PHP 8.6, `is_file()` throws a `ValueError` for a path containing a NUL byte, where earlier versions returned `false`. A request to `ms-files.php` with `%00` in the `file` argument would then end in an uncaught error instead of the existing 404. This returns the 404 before the path reaches `is_file()`. Follow-up to [65552]. See #66793.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
wp-includes/ms-files.phppasses thefilequery argument tois_file()after only removing... PHP decodes%00in a query argument to a NUL byte.Up to PHP 8.5,
is_file()returnsfalsefor a path containing a NUL byte, so such a request ends in the existing 404. As of PHP 8.6,is_file()throws aValueError("Argument #1 ($filename) must not contain any null bytes"), so the same request ends in an uncaught error and a 500 response.This returns the existing 404 before the path reaches
is_file(), in the same check that [65552] added for a missing or non-string value. Behaviour on PHP 8.5 and earlier is unchanged. It only affects networks that still usems-files.php.Testing
I ran the expression
ms-files.phpbuilds, with a NUL byte in the file name, on two PHP builds:is_file()false, no warningValueErrorI have not run the script end to end on a multisite install. There are no unit tests in this change: the script ends in
die(), and [65552] changed the same check without tests. PHPCS passes on the changed file.Trac ticket: https://core.trac.wordpress.org/ticket/66793
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Used for: Tracing request input into the file functions that throw on NUL bytes as of PHP 8.6, writing the change and this description, and running the check above. The results are automated runs by the tool.