summaryrefslogtreecommitdiff
path: root/ext/standard/tests/mail
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-09-11 15:27:54 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-09-11 15:28:51 +0200
commita79008bd91b4188d3474815e0c676685f29d0169 (patch)
tree6440d60a8c139d1da2bde73dc9b9e3a5df8e22c2 /ext/standard/tests/mail
parent4d860005419bf23874fffd1f53663f50be6826e9 (diff)
downloadphp-git-a79008bd91b4188d3474815e0c676685f29d0169.tar.gz
Also forbid null bytes in mail()
I've adjusted mb_send_mail() already, but of course the handling in mail() should be the same.
Diffstat (limited to 'ext/standard/tests/mail')
-rw-r--r--ext/standard/tests/mail/mail_null_bytes.phpt38
1 files changed, 38 insertions, 0 deletions
diff --git a/ext/standard/tests/mail/mail_null_bytes.phpt b/ext/standard/tests/mail/mail_null_bytes.phpt
new file mode 100644
index 0000000000..d25757cb59
--- /dev/null
+++ b/ext/standard/tests/mail/mail_null_bytes.phpt
@@ -0,0 +1,38 @@
+--TEST--
+mail() with null bytes in arguments
+--FILE--
+<?php
+
+try {
+ mail("foo\0bar", "x", "y");
+} catch (ValueError $e) {
+ echo $e->getMessage(), "\n";
+}
+try {
+ mail("x", "foo\0bar", "y");
+} catch (ValueError $e) {
+ echo $e->getMessage(), "\n";
+}
+try {
+ mail("x", "y", "foo\0bar");
+} catch (ValueError $e) {
+ echo $e->getMessage(), "\n";
+}
+try {
+ mail("x", "y", "z", "foo\0bar");
+} catch (ValueError $e) {
+ echo $e->getMessage(), "\n";
+}
+try {
+ mail("x", "y", "z", "q", "foo\0bar");
+} catch (ValueError $e) {
+ echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECT--
+mail(): Argument #1 ($to) must not contain any null bytes
+mail(): Argument #2 ($subject) must not contain any null bytes
+mail(): Argument #3 ($message) must not contain any null bytes
+mail(): Argument #4 ($additional_headers) must not contain any null bytes
+mail(): Argument #5 ($additional_parameters) must not contain any null bytes