diff options
| author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:37:27 -0400 |
|---|---|---|
| committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:37:27 -0400 |
| commit | 2d4e5b09576bb4f0ba716cc82cdf29ea04d9184b (patch) | |
| tree | 41ccc042009cba53e4ce43e727fcba4c1cfbf7f3 /ext/filter/tests | |
| parent | d29a4fd2dd3b5d4cf6e80b602544d7b71d794e76 (diff) | |
| download | php-upstream/5.2.2.tar.gz | |
Imported Upstream version 5.2.2upstream/5.2.2
Diffstat (limited to 'ext/filter/tests')
55 files changed, 925 insertions, 84 deletions
diff --git a/ext/filter/tests/004.phpt b/ext/filter/tests/004.phpt index a0d1b5f2a..b89912493 100644 --- a/ext/filter/tests/004.phpt +++ b/ext/filter/tests/004.phpt @@ -1,11 +1,7 @@ --TEST-- GET/POST/REQUEST Test with filtered data --SKIPIF-- -<?php -/* CGI doesn't read commandline options when it sees REQUES_METHOD */ -die("skip"); -die("not possible to set ini setting using -d and CGI"); -?> +<?php if (!extension_loaded("filter")) die("skip"); ?> --INI-- filter.default=special_chars --POST-- @@ -26,5 +22,5 @@ echo $_REQUEST['d']; echo $_REQUEST['e']; ?> --EXPECT-- -O'HenryBold"quotes"\slash -O'HenryBold"quotes"\slash +O'Henry<b>Bold</b>"quotes"\slash +O'Henry<b>Bold</b>"quotes"\slash diff --git a/ext/filter/tests/006.phpt b/ext/filter/tests/006.phpt index aa612d73d..9439e471c 100644 --- a/ext/filter/tests/006.phpt +++ b/ext/filter/tests/006.phpt @@ -1,5 +1,7 @@ --TEST-- filter() test +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --POST-- foo=<b>abc</b> --FILE-- diff --git a/ext/filter/tests/007.phpt b/ext/filter/tests/007.phpt index 72670dc79..96e0b5f18 100644 --- a/ext/filter/tests/007.phpt +++ b/ext/filter/tests/007.phpt @@ -1,11 +1,7 @@ --TEST-- -input_has_variable() +filter_has_var() --SKIPIF-- -<?php -/* TODO: Check why we get warnings 2x */ -die("skip"); -die("error mode cannot be changed via -d"); -?> +<?php if (!extension_loaded("filter")) die("skip"); ?> --GET-- a=qwe&abc=<a>href</a> --POST-- @@ -13,25 +9,25 @@ b=qwe&bbc=<a>href</a> --FILE-- <?php -var_dump(input_has_variable(INPUT_GET, "a")); -var_dump(input_has_variable(INPUT_GET, "abc")); -var_dump(input_has_variable(INPUT_GET, "nonex")); -var_dump(input_has_variable(INPUT_GET, " ")); -var_dump(input_has_variable(INPUT_GET, "")); -var_dump(input_has_variable(INPUT_GET, array())); +var_dump(filter_has_var(INPUT_GET, "a")); +var_dump(filter_has_var(INPUT_GET, "abc")); +var_dump(filter_has_var(INPUT_GET, "nonex")); +var_dump(filter_has_var(INPUT_GET, " ")); +var_dump(filter_has_var(INPUT_GET, "")); +var_dump(filter_has_var(INPUT_GET, array())); -var_dump(input_has_variable(INPUT_POST, "b")); -var_dump(input_has_variable(INPUT_POST, "bbc")); -var_dump(input_has_variable(INPUT_POST, "nonex")); -var_dump(input_has_variable(INPUT_POST, " ")); -var_dump(input_has_variable(INPUT_POST, "")); -var_dump(input_has_variable(INPUT_POST, array())); +var_dump(filter_has_var(INPUT_POST, "b")); +var_dump(filter_has_var(INPUT_POST, "bbc")); +var_dump(filter_has_var(INPUT_POST, "nonex")); +var_dump(filter_has_var(INPUT_POST, " ")); +var_dump(filter_has_var(INPUT_POST, "")); +var_dump(filter_has_var(INPUT_POST, array())); -var_dump(input_has_variable(-1, "")); -var_dump(input_has_variable("", "")); -var_dump(input_has_variable(array(), array())); -var_dump(input_has_variable(array(), "")); -var_dump(input_has_variable("", array())); +var_dump(filter_has_var(-1, "")); +var_dump(filter_has_var("", "")); +var_dump(filter_has_var(array(), array())); +var_dump(filter_has_var(array(), "")); +var_dump(filter_has_var("", array())); echo "Done\n"; ?> @@ -42,27 +38,27 @@ bool(false) bool(false) bool(false) -Warning: input_has_variable() expects parameter 2 to be string, array given in %s on line %d -NULL +Warning: filter_has_var() expects parameter 2 to be string, array given in %s007.php on line %d +bool(false) bool(true) bool(true) bool(false) bool(false) bool(false) -Warning: input_has_variable() expects parameter 2 to be string, array given in %s on line %d -NULL +Warning: filter_has_var() expects parameter 2 to be string, array given in %s007.php on line %d +bool(false) bool(false) -Warning: input_has_variable() expects parameter 1 to be long, string given in %s on line %d -NULL +Warning: filter_has_var() expects parameter 1 to be long, string given in %s007.php on line %d +bool(false) -Warning: input_has_variable() expects parameter 1 to be long, array given in %s on line %d -NULL +Warning: filter_has_var() expects parameter 1 to be long, array given in %s007.php on line %d +bool(false) -Warning: input_has_variable() expects parameter 1 to be long, array given in %s on line %d -NULL +Warning: filter_has_var() expects parameter 1 to be long, array given in %s007.php on line %d +bool(false) -Warning: input_has_variable() expects parameter 1 to be long, string given in %s on line %d -NULL +Warning: filter_has_var() expects parameter 1 to be long, string given in %s007.php on line %d +bool(false) Done diff --git a/ext/filter/tests/008.phpt b/ext/filter/tests/008.phpt index 5f89910d7..e6c646d67 100644 --- a/ext/filter/tests/008.phpt +++ b/ext/filter/tests/008.phpt @@ -1,5 +1,7 @@ --TEST-- filter_list() +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php diff --git a/ext/filter/tests/009.phpt b/ext/filter/tests/009.phpt index d9d66be07..d09f996fd 100644 --- a/ext/filter/tests/009.phpt +++ b/ext/filter/tests/009.phpt @@ -1,5 +1,7 @@ --TEST-- filter_id() +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php diff --git a/ext/filter/tests/010.phpt b/ext/filter/tests/010.phpt index b1cf124f2..e868c10c4 100644 --- a/ext/filter/tests/010.phpt +++ b/ext/filter/tests/010.phpt @@ -1,5 +1,9 @@ --TEST-- filter_var() +--INI-- +precision=14 +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php @@ -55,6 +59,6 @@ NULL string(1) "1" string(1) "1" string(1) "1" -string(1) "1" -string(1) "1" +bool(false) +bool(false) Done diff --git a/ext/filter/tests/011.phpt b/ext/filter/tests/011.phpt index 1e5d0182c..6a9bf1fa3 100644 --- a/ext/filter/tests/011.phpt +++ b/ext/filter/tests/011.phpt @@ -1,11 +1,9 @@ --TEST-- input_get() +--INI-- +precision=14 --SKIPIF-- -<?php -/* TODO: Check why we get warnings 2x */ -die("skip"); -die("error mode cannot be changed via -d"); -?> +<?php if (!extension_loaded("filter")) die("skip"); ?> --GET-- a=<b>test</b>&b=http://example.com --POST-- @@ -13,20 +11,20 @@ c=<p>string</p>&d=12345.7 --FILE-- <?php ini_set('html_errors', false); -var_dump(input_get(INPUT_GET, "a", FILTER_SANITIZE_STRIPPED)); -var_dump(input_get(INPUT_GET, "b", FILTER_SANITIZE_URL)); -var_dump(input_get(INPUT_GET, "a", FILTER_SANITIZE_SPECIAL_CHARS, array(1,2,3,4,5))); -var_dump(input_get(INPUT_GET, "b", FILTER_VALIDATE_FLOAT, new stdClass)); -var_dump(input_get(INPUT_POST, "c", FILTER_SANITIZE_STRIPPED, array(5,6,7,8))); -var_dump(input_get(INPUT_POST, "d", FILTER_VALIDATE_FLOAT)); -var_dump(input_get(INPUT_POST, "c", FILTER_SANITIZE_SPECIAL_CHARS)); -var_dump(input_get(INPUT_POST, "d", FILTER_VALIDATE_INT)); +var_dump(filter_input(INPUT_GET, "a", FILTER_SANITIZE_STRIPPED)); +var_dump(filter_input(INPUT_GET, "b", FILTER_SANITIZE_URL)); +var_dump(filter_input(INPUT_GET, "a", FILTER_SANITIZE_SPECIAL_CHARS, array(1,2,3,4,5))); +var_dump(filter_input(INPUT_GET, "b", FILTER_VALIDATE_FLOAT, new stdClass)); +var_dump(filter_input(INPUT_POST, "c", FILTER_SANITIZE_STRIPPED, array(5,6,7,8))); +var_dump(filter_input(INPUT_POST, "d", FILTER_VALIDATE_FLOAT)); +var_dump(filter_input(INPUT_POST, "c", FILTER_SANITIZE_SPECIAL_CHARS)); +var_dump(filter_input(INPUT_POST, "d", FILTER_VALIDATE_INT)); -var_dump(input_get(new stdClass, "d")); +var_dump(filter_var(new stdClass, "d")); -var_dump(input_get(INPUT_POST, "c", "", "")); -var_dump(input_get("", "", "", "", "")); -var_dump(input_get(0, 0, 0, 0, 0)); +var_dump(filter_input(INPUT_POST, "c", "", "")); +var_dump(filter_var("", "", "", "", "")); +var_dump(filter_var(0, 0, 0, 0, 0)); echo "Done\n"; ?> @@ -34,19 +32,23 @@ echo "Done\n"; string(4) "test" string(18) "http://example.com" string(27) "<b>test</b>" + +Notice: Object of class stdClass could not be converted to int in %s011.php on line %d bool(false) string(6) "string" float(12345.7) string(29) "<p>string</p>" bool(false) -Warning: input_get() expects parameter 1 to be long, object given in %s on line %d +Warning: filter_var() expects parameter 2 to be long, string given in %s011.php on line %d NULL -Warning: input_get() expects parameter 3 to be long, string given in %s on line %d +Warning: filter_input() expects parameter 3 to be long, string given in %s011.php on line %d NULL -Warning: input_get() expects parameter 1 to be long, string given in %s on line %d +Warning: filter_var() expects at most 3 parameters, 5 given in %s011.php on line %d NULL + +Warning: filter_var() expects at most 3 parameters, 5 given in %s011.php on line %d NULL Done diff --git a/ext/filter/tests/012.phpt b/ext/filter/tests/012.phpt index ef0525489..9a8ead944 100644 --- a/ext/filter/tests/012.phpt +++ b/ext/filter/tests/012.phpt @@ -1,5 +1,7 @@ --TEST-- filter_input() +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php diff --git a/ext/filter/tests/013.phpt b/ext/filter/tests/013.phpt index 55c71e353..421c5d55b 100644 --- a/ext/filter/tests/013.phpt +++ b/ext/filter/tests/013.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() and flags +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php var_dump(filter_var(" 234", FILTER_VALIDATE_INT)); diff --git a/ext/filter/tests/014.phpt b/ext/filter/tests/014.phpt index 77e4d2557..883745714 100644 --- a/ext/filter/tests/014.phpt +++ b/ext/filter/tests/014.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() and FILTER_VALIDATE_BOOLEAN +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php diff --git a/ext/filter/tests/015.phpt b/ext/filter/tests/015.phpt index edde095e7..a9c4a8cf4 100644 --- a/ext/filter/tests/015.phpt +++ b/ext/filter/tests/015.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() and FILTER_VALIDATE_URL +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php @@ -22,6 +24,10 @@ $values = Array( '', -1, array(), +'mailto:foo@bar.com', +'news:news.php.net', +'file://foo/bar', +"http://\r\n/bar", ); foreach ($values as $value) { var_dump(filter_var($value, FILTER_VALIDATE_URL)); @@ -46,18 +52,22 @@ string(32) "http://www.example.com/index.php" string(31) "http://www.example/img/test.png" string(27) "http://www.example/img/dir/" string(26) "http://www.example/img/dir" -string(28) "http//www.example/wrong/url/" -string(17) "http:/www.example" +bool(false) +bool(false) string(18) "file:///tmp/test.c" string(26) "ftp://ftp.example.com/tmp/" -string(11) "/tmp/test.c" -string(1) "/" bool(false) -string(6) "http:/" -string(5) "http:" -string(4) "http" -string(0) "" -string(2) "-1" +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +string(18) "mailto:foo@bar.com" +string(17) "news:news.php.net" +string(14) "file://foo/bar" bool(false) bool(false) string(10) "http://qwe" @@ -68,4 +78,4 @@ bool(false) string(42) "http://www.example.com/path/at/the/server/" bool(false) string(40) "http://www.example.com/index.php?a=b&c=d" -Done +Done
\ No newline at end of file diff --git a/ext/filter/tests/016.phpt b/ext/filter/tests/016.phpt index 67921f018..e013c550a 100644 --- a/ext/filter/tests/016.phpt +++ b/ext/filter/tests/016.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() and FILTER_VALIDATE_EMAIL +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php $values = Array( diff --git a/ext/filter/tests/017.phpt b/ext/filter/tests/017.phpt index 661dfe40f..518ee7925 100644 --- a/ext/filter/tests/017.phpt +++ b/ext/filter/tests/017.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() and FILTER_VALIDATE_REGEXP +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php diff --git a/ext/filter/tests/018.phpt b/ext/filter/tests/018.phpt index 7ea17b329..10840aae7 100644 --- a/ext/filter/tests/018.phpt +++ b/ext/filter/tests/018.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() and FILTER_VALIDATE_IP +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php var_dump(filter_var("192.168.0.1", FILTER_VALIDATE_IP)); diff --git a/ext/filter/tests/019.phpt b/ext/filter/tests/019.phpt index 5a20ff821..1665181cd 100644 --- a/ext/filter/tests/019.phpt +++ b/ext/filter/tests/019.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() & FILTER_VALIDATE_IP and weird data +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php diff --git a/ext/filter/tests/020.phpt b/ext/filter/tests/020.phpt index d39ee55e9..c2ab6096d 100644 --- a/ext/filter/tests/020.phpt +++ b/ext/filter/tests/020.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() and FILTER_SANITIZE_MAGIC_QUOTES +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php diff --git a/ext/filter/tests/021.phpt b/ext/filter/tests/021.phpt index 1dffc9f7a..994dac282 100644 --- a/ext/filter/tests/021.phpt +++ b/ext/filter/tests/021.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() and FILTER_SANITIZE_NUMBER_* +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php diff --git a/ext/filter/tests/022.phpt b/ext/filter/tests/022.phpt index a2ad5a4c3..649c6e409 100644 --- a/ext/filter/tests/022.phpt +++ b/ext/filter/tests/022.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() and FILTER_SANITIZE_EMAIL +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php diff --git a/ext/filter/tests/023.phpt b/ext/filter/tests/023.phpt index b9761a5b7..f8d4137bf 100644 --- a/ext/filter/tests/023.phpt +++ b/ext/filter/tests/023.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() and FILTER_UNSAFE_RAW +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php diff --git a/ext/filter/tests/024.phpt b/ext/filter/tests/024.phpt index bc2cdb400..7d7349fcd 100644 --- a/ext/filter/tests/024.phpt +++ b/ext/filter/tests/024.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() and FILTER_SANITIZE_ENCODED +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php diff --git a/ext/filter/tests/025.phpt b/ext/filter/tests/025.phpt index d1e94abf0..df8c3737b 100644 --- a/ext/filter/tests/025.phpt +++ b/ext/filter/tests/025.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() and FILTER_SANITIZE_STRING +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php @@ -17,7 +19,7 @@ echo "Done\n"; string(0) "" string(0) "" string(12) "!@#$%^&*()'"" -string(32) "!@#$%^&*()&#39;&#34;" +string(24) "!@#$%^&*()'"" string(11) "`1234567890" string(5) "`123`" string(1) "." diff --git a/ext/filter/tests/026.phpt b/ext/filter/tests/026.phpt index 9d66f1144..38d15e7d0 100644 --- a/ext/filter/tests/026.phpt +++ b/ext/filter/tests/026.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() and FILTER_SANITIZE_STRIPPED +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php diff --git a/ext/filter/tests/027.phpt b/ext/filter/tests/027.phpt index c187960a0..759030a64 100644 --- a/ext/filter/tests/027.phpt +++ b/ext/filter/tests/027.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() and FILTER_SANITIZE_ENCODED +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php diff --git a/ext/filter/tests/028.phpt b/ext/filter/tests/028.phpt index 4ffb0fd1f..c0ab16fe8 100644 --- a/ext/filter/tests/028.phpt +++ b/ext/filter/tests/028.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() and FILTER_SANITIZE_SPECIAL_CHARS +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php diff --git a/ext/filter/tests/029.phpt b/ext/filter/tests/029.phpt index d0979f1e3..c1ede74ab 100644 --- a/ext/filter/tests/029.phpt +++ b/ext/filter/tests/029.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() and FILTER_CALLBACK +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php diff --git a/ext/filter/tests/030.phpt b/ext/filter/tests/030.phpt index 97b62b9e2..d3466f5b4 100644 --- a/ext/filter/tests/030.phpt +++ b/ext/filter/tests/030.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() and IPv6 +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php $ipv6_test = array( @@ -19,7 +21,13 @@ $ipv6_test = array( "0:0:0:0:0:FFFF:129.144.52.38" => true, "0:0:0:0:0:0:13.1.68.3" => true, "::13.1.68.3" => true, - "::FFFF:129.144.52.38" => true + "::FFFF:129.144.52.38" => true, + "1:2:3:4:5:6::129.144.52.38" => false, + "::1:2:3:4:5:6:129.144.52.38" => false, + "1:2:3::4:5:6:129.144.52.38" => false, + "1:2:3:4:5:6:7:8::" => false, + "::1:2:3:4:5:6:7:8" => false, + "1:2:3:4::5:6:7:8" => false, ); foreach ($ipv6_test as $ip => $exp) { $out = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6); diff --git a/ext/filter/tests/031.phpt b/ext/filter/tests/031.phpt index 74883b8b2..02ef90a34 100644 --- a/ext/filter/tests/031.phpt +++ b/ext/filter/tests/031.phpt @@ -1,5 +1,7 @@ --TEST-- filter_var() and FLOAT +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php diff --git a/ext/filter/tests/032.phpt b/ext/filter/tests/032.phpt index cc6abd4f0..d88d50279 100644 --- a/ext/filter/tests/032.phpt +++ b/ext/filter/tests/032.phpt @@ -1,5 +1,7 @@ --TEST-- input_get_args() +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php $data = array( diff --git a/ext/filter/tests/033.phpt b/ext/filter/tests/033.phpt index 2a679d50c..18a361690 100644 --- a/ext/filter/tests/033.phpt +++ b/ext/filter/tests/033.phpt @@ -1,5 +1,7 @@ --TEST-- Test all filters returned by filter_list() +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php include dirname(__FILE__) . '/033_run.inc'; @@ -9,7 +11,7 @@ int 1 123 boolean 1 float 1 123 validate_regexp O'Henry -validate_url PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc<>() O'Henry 하퍼 +validate_url http://a.b.c validate_email foo@bar.com validate_ip 1.2.3.4 string PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc() O'Henry 하퍼 diff --git a/ext/filter/tests/033_run.inc b/ext/filter/tests/033_run.inc index c77d888ac..e3b67387c 100644 --- a/ext/filter/tests/033_run.inc +++ b/ext/filter/tests/033_run.inc @@ -1,7 +1,12 @@ <?php +if (function_exists('setlocale')) { + setlocale(LC_ALL, 'C'); +} + function test($data) { return strtoupper($data); } + $data = array( "PHP", "1", diff --git a/ext/filter/tests/034.phpt b/ext/filter/tests/034.phpt index f96596d7c..364f9024f 100644 --- a/ext/filter/tests/034.phpt +++ b/ext/filter/tests/034.phpt @@ -1,5 +1,7 @@ --TEST-- Logical filter: boolean +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php $booleans = array( diff --git a/ext/filter/tests/035.phpt b/ext/filter/tests/035.phpt index e85444322..e2d332527 100644 --- a/ext/filter/tests/035.phpt +++ b/ext/filter/tests/035.phpt @@ -1,5 +1,7 @@ --TEST-- GET/POST/REQUEST Test with input_filter +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --POST-- d=379 --GET-- diff --git a/ext/filter/tests/037.phpt b/ext/filter/tests/037.phpt index 9e91288cb..f8497c63b 100644 --- a/ext/filter/tests/037.phpt +++ b/ext/filter/tests/037.phpt @@ -1,5 +1,7 @@ --TEST-- GET and data callback tests +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --GET-- a=1&b=2 --FILE-- diff --git a/ext/filter/tests/038.phpt b/ext/filter/tests/038.phpt index d74e5f27e..998c80fe8 100644 --- a/ext/filter/tests/038.phpt +++ b/ext/filter/tests/038.phpt @@ -1,5 +1,7 @@ --TEST-- Test scalar, array +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php diff --git a/ext/filter/tests/039.phpt b/ext/filter/tests/039.phpt new file mode 100644 index 000000000..ae883db3e --- /dev/null +++ b/ext/filter/tests/039.phpt @@ -0,0 +1,117 @@ +--TEST-- +filter_var_array() and different arguments +--SKIPIF-- +<?php if (!extension_loaded("filter")) print "skip"; ?> +--FILE-- +<?php + +echo "-- (1)\n"; +var_dump(filter_var_array(NULL)); +var_dump(filter_var_array(array())); +var_dump(filter_var_array(array(1,"blah"=>"hoho"))); +var_dump(filter_var_array(array(), -1)); +var_dump(filter_var_array(array(), 1000000)); +var_dump(filter_var_array(array(), "")); + +echo "-- (2)\n"; +var_dump(filter_var_array(array(""=>""), -1)); +var_dump(filter_var_array(array(""=>""), 1000000)); +var_dump(filter_var_array(array(""=>""), "")); + +echo "-- (3)\n"; +var_dump(filter_var_array(array("aaa"=>"bbb"), -1)); +var_dump(filter_var_array(array("aaa"=>"bbb"), 1000000)); +var_dump(filter_var_array(array("aaa"=>"bbb"), "")); + +echo "-- (4)\n"; +var_dump(filter_var_array(array(), new stdclass)); +var_dump(filter_var_array(array(), array())); +var_dump(filter_var_array(array(), array("var_name"=>1))); +var_dump(filter_var_array(array(), array("var_name"=>-1))); +var_dump(filter_var_array(array("var_name"=>""), array("var_name"=>-1))); + +echo "-- (5)\n"; +var_dump(filter_var_array(array("var_name"=>""), array("var_name"=>-1, "asdas"=>"asdasd", "qwe"=>"rty", ""=>""))); +var_dump(filter_var_array(array("asdas"=>"text"), array("var_name"=>-1, "asdas"=>"asdasd", "qwe"=>"rty", ""=>""))); + + +$a = array(""=>""); $b = -1; +var_dump(filter_var_array($a, $b)); +var_dump($a, $b); + +$a = array(""=>""); $b = 100000; +var_dump(filter_var_array($a, $b)); +var_dump($a, $b); + +$a = array(""=>""); $b = ""; +var_dump(filter_var_array($a, $b)); +var_dump($a, $b); + +echo "Done\n"; +?> +--EXPECTF-- +-- (1) + +Warning: filter_var_array() expects parameter 1 to be array, null given in %s on line %d +NULL +array(0) { +} +array(2) { + [0]=> + string(1) "1" + ["blah"]=> + string(4) "hoho" +} +bool(false) +bool(false) +bool(false) +-- (2) +bool(false) +bool(false) +bool(false) +-- (3) +bool(false) +bool(false) +bool(false) +-- (4) +bool(false) +array(0) { +} +array(1) { + ["var_name"]=> + NULL +} +array(1) { + ["var_name"]=> + NULL +} +array(1) { + ["var_name"]=> + string(0) "" +} +-- (5) + +Warning: filter_var_array(): Empty keys are not allowed in the definition array in %s on line %d +bool(false) + +Warning: filter_var_array(): Empty keys are not allowed in the definition array in %s on line %d +bool(false) +bool(false) +array(1) { + [""]=> + string(0) "" +} +int(-1) +bool(false) +array(1) { + [""]=> + string(0) "" +} +int(100000) +bool(false) +array(1) { + [""]=> + string(0) "" +} +string(0) "" +Done diff --git a/ext/filter/tests/040.phpt b/ext/filter/tests/040.phpt new file mode 100644 index 000000000..fd39b369d --- /dev/null +++ b/ext/filter/tests/040.phpt @@ -0,0 +1,45 @@ +--TEST-- +filter_has_var() tests +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> +--GET-- +a=1&b=2&c=0 +--POST-- +ap[]=1&bp=test&cp= +--FILE-- +<?php + +var_dump(filter_has_var()); +var_dump(filter_has_var(INPUT_GET,"")); +var_dump(filter_has_var(INPUT_GET,array())); +var_dump(filter_has_var(INPUT_POST, "ap")); +var_dump(filter_has_var(INPUT_POST, "cp")); +var_dump(filter_has_var(INPUT_GET, "a")); +var_dump(filter_has_var(INPUT_GET, "c")); +var_dump(filter_has_var(INPUT_GET, "abc")); +var_dump(filter_has_var(INPUT_GET, "cc")); +var_dump(filter_has_var(-1, "cc")); +var_dump(filter_has_var(0, "cc")); +var_dump(filter_has_var("", "cc")); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: filter_has_var() expects exactly 2 parameters, 0 given in %s on line %d +bool(false) +bool(false) + +Warning: filter_has_var() expects parameter 2 to be string, array given in %s on line %d +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +bool(false) +bool(false) + +Warning: filter_has_var() expects parameter 1 to be long, string given in %s on line %d +bool(false) +Done diff --git a/ext/filter/tests/041.phpt b/ext/filter/tests/041.phpt new file mode 100644 index 000000000..0a2e3f0a1 --- /dev/null +++ b/ext/filter/tests/041.phpt @@ -0,0 +1,34 @@ +--TEST-- +COOKIE multiple cookie test +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> +--INI-- +filter.default=stripped +filter.default_flags=0 +--COOKIE-- +abc=dir; def=true; abc=root; xyz="foo bar"; +--FILE-- +<?php +var_dump($_COOKIE); +var_dump(filter_has_var(INPUT_COOKIE, "abc")); +var_dump(filter_input(INPUT_COOKIE, "abc")); +var_dump(filter_input(INPUT_COOKIE, "def")); +var_dump(filter_input(INPUT_COOKIE, "xyz")); +var_dump(filter_has_var(INPUT_COOKIE, "bogus")); +var_dump(filter_input(INPUT_COOKIE, "xyz", FILTER_SANITIZE_SPECIAL_CHARS)); +?> +--EXPECT-- +array(3) { + ["abc"]=> + string(3) "dir" + ["def"]=> + string(4) "true" + ["xyz"]=> + string(17) ""foo bar"" +} +bool(true) +string(3) "dir" +string(4) "true" +string(9) ""foo bar"" +bool(false) +string(17) ""foo bar"" diff --git a/ext/filter/tests/042.phpt b/ext/filter/tests/042.phpt new file mode 100644 index 000000000..08f4dd633 --- /dev/null +++ b/ext/filter/tests/042.phpt @@ -0,0 +1,19 @@ +--TEST-- +Combination of strip & sanitize filters +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> +--FILE-- +<?php +$var = 'XYZ< script>alert(/ext/filter+bypass/);< /script>ABC'; +$a = filter_var($var, FILTER_SANITIZE_STRING, array("flags" => FILTER_FLAG_STRIP_LOW)); +echo $a . "\n"; + +$var = 'XYZ< +script>alert(/ext/filter+bypass/);< +/script>ABC'; +$a = filter_var($var, FILTER_SANITIZE_STRING, array("flags" => FILTER_FLAG_STRIP_LOW)); +echo $a . "\n"; +?> +--EXPECT-- +XYZalert(/ext/filter+bypass/);ABC +XYZalert(/ext/filter+bypass/);ABC diff --git a/ext/filter/tests/043.phpt b/ext/filter/tests/043.phpt new file mode 100644 index 000000000..92ac0517d --- /dev/null +++ b/ext/filter/tests/043.phpt @@ -0,0 +1,269 @@ +--TEST-- +Character encoding test +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> +--FILE-- +<?php +$flags = FILTER_FLAG_ENCODE_AMP|FILTER_FLAG_ENCODE_LOW|FILTER_FLAG_ENCODE_HIGH; + +for ($i = 0; $i < 256; $i++) { + var_dump(filter_var(chr($i), FILTER_SANITIZE_STRING, array("flags" => $flags))); +} +?> +--EXPECT-- +string(4) "�" +string(4) "" +string(4) "" +string(4) "" +string(4) "" +string(4) "" +string(4) "" +string(4) "" +string(4) "" +string(4) "	" +string(5) " " +string(5) "" +string(5) "" +string(5) " " +string(5) "" +string(5) "" +string(5) "" +string(5) "" +string(5) "" +string(5) "" +string(5) "" +string(5) "" +string(5) "" +string(5) "" +string(5) "" +string(5) "" +string(5) "" +string(5) "" +string(5) "" +string(5) "" +string(5) "" +string(5) "" +string(1) " " +string(1) "!" +string(5) """ +string(1) "#" +string(1) "$" +string(1) "%" +string(5) "&" +string(5) "'" +string(1) "(" +string(1) ")" +string(1) "*" +string(1) "+" +string(1) "," +string(1) "-" +string(1) "." +string(1) "/" +string(1) "0" +string(1) "1" +string(1) "2" +string(1) "3" +string(1) "4" +string(1) "5" +string(1) "6" +string(1) "7" +string(1) "8" +string(1) "9" +string(1) ":" +string(1) ";" +string(0) "" +string(1) "=" +string(1) ">" +string(1) "?" +string(1) "@" +string(1) "A" +string(1) "B" +string(1) "C" +string(1) "D" +string(1) "E" +string(1) "F" +string(1) "G" +string(1) "H" +string(1) "I" +string(1) "J" +string(1) "K" +string(1) "L" +string(1) "M" +string(1) "N" +string(1) "O" +string(1) "P" +string(1) "Q" +string(1) "R" +string(1) "S" +string(1) "T" +string(1) "U" +string(1) "V" +string(1) "W" +string(1) "X" +string(1) "Y" +string(1) "Z" +string(1) "[" +string(1) "\" +string(1) "]" +string(1) "^" +string(1) "_" +string(1) "`" +string(1) "a" +string(1) "b" +string(1) "c" +string(1) "d" +string(1) "e" +string(1) "f" +string(1) "g" +string(1) "h" +string(1) "i" +string(1) "j" +string(1) "k" +string(1) "l" +string(1) "m" +string(1) "n" +string(1) "o" +string(1) "p" +string(1) "q" +string(1) "r" +string(1) "s" +string(1) "t" +string(1) "u" +string(1) "v" +string(1) "w" +string(1) "x" +string(1) "y" +string(1) "z" +string(1) "{" +string(1) "|" +string(1) "}" +string(1) "~" +string(6) "" +string(6) "€" +string(6) "" +string(6) "‚" +string(6) "ƒ" +string(6) "„" +string(6) "…" +string(6) "†" +string(6) "‡" +string(6) "ˆ" +string(6) "‰" +string(6) "Š" +string(6) "‹" +string(6) "Œ" +string(6) "" +string(6) "Ž" +string(6) "" +string(6) "" +string(6) "‘" +string(6) "’" +string(6) "“" +string(6) "”" +string(6) "•" +string(6) "–" +string(6) "—" +string(6) "˜" +string(6) "™" +string(6) "š" +string(6) "›" +string(6) "œ" +string(6) "" +string(6) "ž" +string(6) "Ÿ" +string(6) " " +string(6) "¡" +string(6) "¢" +string(6) "£" +string(6) "¤" +string(6) "¥" +string(6) "¦" +string(6) "§" +string(6) "¨" +string(6) "©" +string(6) "ª" +string(6) "«" +string(6) "¬" +string(6) "­" +string(6) "®" +string(6) "¯" +string(6) "°" +string(6) "±" +string(6) "²" +string(6) "³" +string(6) "´" +string(6) "µ" +string(6) "¶" +string(6) "·" +string(6) "¸" +string(6) "¹" +string(6) "º" +string(6) "»" +string(6) "¼" +string(6) "½" +string(6) "¾" +string(6) "¿" +string(6) "À" +string(6) "Á" +string(6) "Â" +string(6) "Ã" +string(6) "Ä" +string(6) "Å" +string(6) "Æ" +string(6) "Ç" +string(6) "È" +string(6) "É" +string(6) "Ê" +string(6) "Ë" +string(6) "Ì" +string(6) "Í" +string(6) "Î" +string(6) "Ï" +string(6) "Ð" +string(6) "Ñ" +string(6) "Ò" +string(6) "Ó" +string(6) "Ô" +string(6) "Õ" +string(6) "Ö" +string(6) "×" +string(6) "Ø" +string(6) "Ù" +string(6) "Ú" +string(6) "Û" +string(6) "Ü" +string(6) "Ý" +string(6) "Þ" +string(6) "ß" +string(6) "à" +string(6) "á" +string(6) "â" +string(6) "ã" +string(6) "ä" +string(6) "å" +string(6) "æ" +string(6) "ç" +string(6) "è" +string(6) "é" +string(6) "ê" +string(6) "ë" +string(6) "ì" +string(6) "í" +string(6) "î" +string(6) "ï" +string(6) "ð" +string(6) "ñ" +string(6) "ò" +string(6) "ó" +string(6) "ô" +string(6) "õ" +string(6) "ö" +string(6) "÷" +string(6) "ø" +string(6) "ù" +string(6) "ú" +string(6) "û" +string(6) "ü" +string(6) "ý" +string(6) "þ" +string(6) "ÿ" diff --git a/ext/filter/tests/044.phpt b/ext/filter/tests/044.phpt new file mode 100644 index 000000000..6fa6c2e30 --- /dev/null +++ b/ext/filter/tests/044.phpt @@ -0,0 +1,23 @@ +--TEST-- +Integer validation with spaces +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> +--FILE-- +<?php +$vals = array( +" + ", +" ", +" 123", +" 123.01 ", +); + +foreach ($vals as $var) { + var_dump(filter_var($var, FILTER_VALIDATE_FLOAT)); +} +?> +--EXPECT-- +bool(false) +bool(false) +float(123) +float(123.01) diff --git a/ext/filter/tests/045.phpt b/ext/filter/tests/045.phpt new file mode 100755 index 000000000..22b871005 --- /dev/null +++ b/ext/filter/tests/045.phpt @@ -0,0 +1,30 @@ +--TEST--
+Options must not be changed by filter_var()
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+$a = array("flags"=>(string)FILTER_FLAG_ALLOW_HEX, "options" => array("min_range"=>"0", "max_range"=>"1024"));
+$ret = filter_var("0xff", FILTER_VALIDATE_INT, $a);
+echo ($ret === 255 && $a["options"]["min_range"] === "0")?"ok\n":"bug\n";
+echo ($ret === 255 && $a["options"]["max_range"] === "1024")?"ok\n":"bug\n";
+echo ($ret === 255 && is_string($a["flags"]) && $a["flags"] == FILTER_FLAG_ALLOW_HEX)?"ok\n":"bug\n";
+$a = (string)FILTER_FLAG_ALLOW_HEX;
+$ret = filter_var("0xff", FILTER_VALIDATE_INT, $a);
+echo ($ret === 255 && is_string($a) && $a == FILTER_FLAG_ALLOW_HEX)?"ok\n":"bug\n";
+$a = array("test"=>array("filter"=>(string)FILTER_VALIDATE_INT, "flags"=>(string)FILTER_FLAG_ALLOW_HEX));
+$ret = filter_var_array(array("test"=>"0xff"), $a);
+echo ($ret["test"] === 255 && is_string($a["test"]["filter"]) && $a["test"]["filter"] == FILTER_VALIDATE_INT)?"ok\n":"bug\n";
+echo ($ret["test"] === 255 && is_string($a["test"]["flags"]) && $a["test"]["flags"] == FILTER_FLAG_ALLOW_HEX)?"ok\n":"bug\n";
+$a = array("test"=>(string)FILTER_VALIDATE_INT);
+$ret = filter_var_array(array("test"=>"255"), $a);
+echo ($ret["test"] === 255 && is_string($a["test"]) && $a["test"] == FILTER_VALIDATE_INT)?"ok\n":"bug\n";
+?>
+--EXPECT--
+ok
+ok
+ok
+ok
+ok
+ok
+ok
diff --git a/ext/filter/tests/046.phpt b/ext/filter/tests/046.phpt new file mode 100755 index 000000000..4ab1ce62e --- /dev/null +++ b/ext/filter/tests/046.phpt @@ -0,0 +1,23 @@ +--TEST--
+Integer overflow
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+$s = sprintf("%d", PHP_INT_MAX);
+var_dump(is_long(filter_var($s, FILTER_VALIDATE_INT)));
+
+$s = sprintf("%.0f", PHP_INT_MAX+1);
+var_dump(filter_var($s, FILTER_VALIDATE_INT));
+
+$s = sprintf("%d", -PHP_INT_MAX);
+var_dump(is_long(filter_var($s, FILTER_VALIDATE_INT)));
+
+$s = sprintf("%.0f", -(PHP_INT_MAX+1));
+var_dump(filter_var($s, FILTER_VALIDATE_INT));
+?>
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+bool(false)
diff --git a/ext/filter/tests/047.phpt b/ext/filter/tests/047.phpt new file mode 100755 index 000000000..9bcb66691 --- /dev/null +++ b/ext/filter/tests/047.phpt @@ -0,0 +1,37 @@ +--TEST--
+Octal integer overflow
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+function octal_inc($s) {
+ $len = strlen($s);
+ while ($len > 0) {
+ $len--;
+ if ($s[$len] != '7') {
+ $s[$len] = $s[$len] + 1;
+ return $s;
+ }
+ $s[$len] = '0';
+ }
+ return '1'.$s;
+}
+
+
+$s = sprintf("%o", PHP_INT_MAX);
+var_dump(is_long(filter_var('0'.$s, FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))));
+
+$s = octal_inc($s);
+var_dump(is_long(filter_var('0'.$s, FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))));
+
+$s = sprintf("%o", ~0);
+var_dump(is_long(filter_var('0'.$s, FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))));
+
+$s = octal_inc($s);
+var_dump(filter_var('0'.$s, FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL)));
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(false)
diff --git a/ext/filter/tests/048.phpt b/ext/filter/tests/048.phpt new file mode 100755 index 000000000..c4436c400 --- /dev/null +++ b/ext/filter/tests/048.phpt @@ -0,0 +1,41 @@ +--TEST--
+Hex integer overflow
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+function hex_inc($s) {
+ $len = strlen($s);
+ while ($len > 0) {
+ $len--;
+ if ($s[$len] != 'f') {
+ if ($s[$len] == '9') {
+ $s[$len] = 'a';
+ } else {
+ $s[$len] = $s[$len] + 1;
+ }
+ return $s;
+ }
+ $s[$len] = '0';
+ }
+ return '1'.$s;
+}
+
+
+$s = sprintf("%x", PHP_INT_MAX);
+var_dump(is_long(filter_var('0x'.$s, FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_HEX))));
+
+$s = hex_inc($s);
+var_dump(is_long(filter_var('0x'.$s, FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_HEX))));
+
+$s = sprintf("%x", ~0);
+var_dump(is_long(filter_var('0x'.$s, FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_HEX))));
+
+$s = hex_inc($s);
+var_dump(filter_var('0x'.$s, FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_HEX)));
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(false)
diff --git a/ext/filter/tests/049.phpt b/ext/filter/tests/049.phpt new file mode 100755 index 000000000..c87e7056d --- /dev/null +++ b/ext/filter/tests/049.phpt @@ -0,0 +1,34 @@ +--TEST--
+filter_var() and doubles with thousend separators
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+$test = array(
+ '0' => 0.0,
+ '12345678900.1234567165' => 12345678900.1234567165,
+ '1,234,567,890.1234567165' => 1234567890.1234567165,
+ '-1,234,567,890.1234567165' => -1234567890.1234567165,
+ '1234,567,890.1234567165' => false,
+ '1,234,567,89.1234567165' => false,
+ '1,234,567,8900.1234567165' => false,
+ '1.234.567.890.1234567165' => false,
+ '1,234,567,8900.123,456' => false,
+);
+foreach ($test as $src => $dst) {
+ $out = filter_var($src, FILTER_VALIDATE_FLOAT, array("flags"=>FILTER_FLAG_ALLOW_THOUSAND));
+ if ($dst !== $out) {
+ if ($out === false) {
+ echo "$src -> false != $dst\n";
+ } elseif ($dst === false) {
+ echo "$src -> $out != false\n";
+ } else {
+ echo "$src -> $out != $dst\n";
+ }
+ }
+}
+
+echo "Ok\n";
+?>
+--EXPECT--
+Ok
diff --git a/ext/filter/tests/050.phpt b/ext/filter/tests/050.phpt new file mode 100755 index 000000000..fb6b6922d --- /dev/null +++ b/ext/filter/tests/050.phpt @@ -0,0 +1,29 @@ +--TEST--
+filter_var() and double overflow/underflow
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+$test = array(
+ '1e+308' => 1e+308,
+ '1e+309' => false,
+ '1e-323' => 1e-323,
+ '1e-324' => false,
+);
+foreach ($test as $src => $dst) {
+ $out = filter_var($src, FILTER_VALIDATE_FLOAT);
+ if ($dst !== $out) {
+ if ($out === false) {
+ echo "$src -> false != $dst\n";
+ } elseif ($dst === false) {
+ echo "$src -> $out != false\n";
+ } else {
+ echo "$src -> $out != $dst\n";
+ }
+ }
+}
+
+echo "Ok\n";
+?>
+--EXPECT--
+Ok
diff --git a/ext/filter/tests/051.phpt b/ext/filter/tests/051.phpt new file mode 100755 index 000000000..1a5f166da --- /dev/null +++ b/ext/filter/tests/051.phpt @@ -0,0 +1,11 @@ +--TEST--
+filter_var() and default values
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+$tmp = $default = 321;
+var_dump(filter_var("123asd", FILTER_VALIDATE_INT, array("options"=>array("default"=>$default))));
+?>
+--EXPECT--
+int(321)
diff --git a/ext/filter/tests/bug39763.phpt b/ext/filter/tests/bug39763.phpt new file mode 100644 index 000000000..cc8d9ccee --- /dev/null +++ b/ext/filter/tests/bug39763.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #39763 filter applies magic_quotes twice in parse_str() +--INI-- +magic_quotes_gpc=1 +filter.default= +--FILE-- +<?php +$arr = array(); +parse_str("val=%22probably+a+bug%22", $arr); +echo $arr['val'] . "\n"; +parse_str("val=%22probably+a+bug%22"); +echo $val . "\n"; +?> +--EXPECT-- +\"probably a bug\" +\"probably a bug\" diff --git a/ext/filter/tests/bug39846.phpt b/ext/filter/tests/bug39846.phpt new file mode 100644 index 000000000..57407f108 --- /dev/null +++ b/ext/filter/tests/bug39846.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #39846 (ipv4 trailing data validation) +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> +--FILE-- +<?php +var_dump(filter_var('192.168.1.100random-text-here', FILTER_VALIDATE_IP)); +var_dump(filter_var("192.168.1.155\0foo", FILTER_VALIDATE_IP)); +?> +--EXPECT-- +bool(false) +bool(false) diff --git a/ext/filter/tests/bug7586.phpt b/ext/filter/tests/bug7586.phpt index d9ea723f4..74e55ff71 100644 --- a/ext/filter/tests/bug7586.phpt +++ b/ext/filter/tests/bug7586.phpt @@ -1,5 +1,7 @@ --TEST-- input_get_args() filter not reseted between elements +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php $data = array( diff --git a/ext/filter/tests/bug7715.phpt b/ext/filter/tests/bug7715.phpt index 3372f756d..4298d505d 100644 --- a/ext/filter/tests/bug7715.phpt +++ b/ext/filter/tests/bug7715.phpt @@ -1,5 +1,9 @@ --TEST-- bug 7715, floats value with integer or incomplete input +--INI-- +precision=14 +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php $data = array( @@ -24,6 +28,6 @@ float(-42) float(42) float(0.4) float(-0.4) -float(1.0E+12) -float(-1.0E+12) +float(1000000000000) +float(-1000000000000) float(2.324) diff --git a/ext/filter/tests/bug7733.phpt b/ext/filter/tests/bug7733.phpt index 07b4b0c72..ab0212390 100644 --- a/ext/filter/tests/bug7733.phpt +++ b/ext/filter/tests/bug7733.phpt @@ -1,5 +1,7 @@ --TEST-- filter_data() Float exponential weird result +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php $data = array( @@ -15,13 +17,13 @@ var_dump($out); --EXPECTF-- array(5) { [0]=> - float(0) + bool(false) [1]=> - float(10) + bool(false) [2]=> - float(2) + bool(false) [3]=> - float(0) + bool(false) [4]=> - float(0) + bool(false) } diff --git a/ext/filter/tests/bug8315.phpt b/ext/filter/tests/bug8315.phpt index ab1a0937e..094d82f21 100644 --- a/ext/filter/tests/bug8315.phpt +++ b/ext/filter/tests/bug8315.phpt @@ -1,5 +1,7 @@ --TEST-- bug 8315, NULL values halt the validation +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php diff --git a/ext/filter/tests/callback_non_modified_var.phpt b/ext/filter/tests/callback_non_modified_var.phpt new file mode 100644 index 000000000..f0d557577 --- /dev/null +++ b/ext/filter/tests/callback_non_modified_var.phpt @@ -0,0 +1,14 @@ +--TEST-- +callback function returns non modified value +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> +--FILE-- +<?php +function callback($var) { + return $var; +} +$var = "test"; +var_dump(filter_var($var, FILTER_CALLBACK, array('options'=>'callback'))); +?> +--EXPECT-- +string(4) "test" diff --git a/ext/filter/tests/filter_data.phpt b/ext/filter/tests/filter_data.phpt index 14e8545c9..6926a8851 100644 --- a/ext/filter/tests/filter_data.phpt +++ b/ext/filter/tests/filter_data.phpt @@ -1,5 +1,7 @@ --TEST-- Simple filter_var() tests +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php |
