From 7e339a335e87d9c8d0b6994039220890284df63e Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 8 Sep 2020 12:12:26 +0200 Subject: Make null byte error a ValueError Currently we treat paths with null bytes as a TypeError, which is incorrect, and rather inconsistent, as we treat empty paths as ValueError. We do this because the error is generated by zpp and it's easier to always throw TypeError there. This changes the zpp implementation to throw a TypeError only if the type is actually wrong and throw ValueError for null bytes. The error message is also split accordingly, to be more precise. Closes GH-6094. --- ext/standard/tests/file/bug39863.phpt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ext/standard/tests/file/bug39863.phpt') diff --git a/ext/standard/tests/file/bug39863.phpt b/ext/standard/tests/file/bug39863.phpt index 982367cccb..c69cb6d0a6 100644 --- a/ext/standard/tests/file/bug39863.phpt +++ b/ext/standard/tests/file/bug39863.phpt @@ -9,9 +9,9 @@ $filename = __FILE__ . chr(0). ".ridiculous"; try { var_dump(file_exists($filename)); -} catch (TypeError $e) { +} catch (ValueError $e) { echo $e->getMessage(), "\n"; } ?> --EXPECT-- -file_exists(): Argument #1 ($filename) must be a valid path, string given +file_exists(): Argument #1 ($filename) must not contain any null bytes -- cgit v1.2.1