xref: /PHP-8.2/ext/filter/tests/058.phpt (revision 74859783)
1--TEST--
2FILTER_VALIDATE_EMAIL unicode support (https://tools.ietf.org/html/rfc6531)
3--EXTENSIONS--
4filter
5--FILE--
6<?php
7$values = Array(
8'niceändsimple@example.com',
9'véry.çommon@example.com',
10'a.lîttle.lengthy.but.fiñe@dept.example.com',
11'dîsposable.style.émail.with+symbol@example.com',
12'other.émail-with-dash@example.com',
13'üser@[IPv6:2001:db8:1ff::a0b:dbd0]',
14'"verî.uñusual.@.uñusual.com"@example.com',
15'"verî.(),:;<>[]\".VERÎ.\"verî@\ \"verî\".unüsual"@strange.example.com',
16'tést@example.com',
17'tést.child@example.com',
18'tést@xn--exmple-cua.com',
19'tést@xn----zfa.xe',
20'tést@subexample.wizard',
21'tést@[255.255.255.255]',
22'tést@[IPv6:2001:0db8:85a3:08d3:1319:8a2e:0370:7344]',
23'tést@[IPv6:2001::7344]',
24'tést@[IPv6:1111:2222:3333:4444:5555:6666:255.255.255.255]',
25'tést+reference@example.com',
26'üñîçøðé@example.com',
27'"üñîçøðé"@example.com',
28'DžǼ੧ఘⅧ⒇৪@example.com',
29);
30foreach ($values as $value) {
31    var_dump(filter_var($value, FILTER_VALIDATE_EMAIL, FILTER_FLAG_EMAIL_UNICODE));
32}
33echo "Done\n";
34?>
35--EXPECT--
36string(26) "niceändsimple@example.com"
37string(25) "véry.çommon@example.com"
38string(44) "a.lîttle.lengthy.but.fiñe@dept.example.com"
39string(48) "dîsposable.style.émail.with+symbol@example.com"
40string(34) "other.émail-with-dash@example.com"
41string(35) "üser@[IPv6:2001:db8:1ff::a0b:dbd0]"
42string(43) ""verî.uñusual.@.uñusual.com"@example.com"
43string(74) ""verî.(),:;<>[]\".VERÎ.\"verî@\ \"verî\".unüsual"@strange.example.com"
44string(17) "tést@example.com"
45string(23) "tést.child@example.com"
46string(24) "tést@xn--exmple-cua.com"
47string(18) "tést@xn----zfa.xe"
48string(23) "tést@subexample.wizard"
49string(23) "tést@[255.255.255.255]"
50string(52) "tést@[IPv6:2001:0db8:85a3:08d3:1319:8a2e:0370:7344]"
51string(23) "tést@[IPv6:2001::7344]"
52string(58) "tést@[IPv6:1111:2222:3333:4444:5555:6666:255.255.255.255]"
53string(27) "tést+reference@example.com"
54string(26) "üñîçøðé@example.com"
55string(28) ""üñîçøðé"@example.com"
56string(31) "DžǼ੧ఘⅧ⒇৪@example.com"
57Done
58