aharvey Wed, 03 Mar 2010 09:25:50 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=295773
Log: Fix for bug #51192 (FILTER_VALIDATE_URL will invalidate a hostname that includes '-'). Original patch by so...@azrael.ws. Bug: http://bugs.php.net/51192 (Assigned) FILTER_VALIDATE_URL will invalidate a hostname that includes '-' Changed paths: U php/php-src/branches/PHP_5_2/ext/filter/logical_filters.c A php/php-src/branches/PHP_5_2/ext/filter/tests/bug51192.phpt U php/php-src/branches/PHP_5_3/ext/filter/logical_filters.c A php/php-src/branches/PHP_5_3/ext/filter/tests/bug51192.phpt U php/php-src/trunk/ext/filter/logical_filters.c A php/php-src/trunk/ext/filter/tests/bug51192.phpt Modified: php/php-src/branches/PHP_5_2/ext/filter/logical_filters.c =================================================================== --- php/php-src/branches/PHP_5_2/ext/filter/logical_filters.c 2010-03-03 06:31:15 UTC (rev 295772) +++ php/php-src/branches/PHP_5_2/ext/filter/logical_filters.c 2010-03-03 09:25:50 UTC (rev 295773) @@ -467,7 +467,7 @@ s = url->host; while (s < e) { - if (!isalnum((int)*(unsigned char *)s) && *s != '_' && *s != '.') { + if (!isalnum((int)*(unsigned char *)s) && *s != '-' && *s != '.') { goto bad_url; } s++; Added: php/php-src/branches/PHP_5_2/ext/filter/tests/bug51192.phpt =================================================================== --- php/php-src/branches/PHP_5_2/ext/filter/tests/bug51192.phpt (rev 0) +++ php/php-src/branches/PHP_5_2/ext/filter/tests/bug51192.phpt 2010-03-03 09:25:50 UTC (rev 295773) @@ -0,0 +1,13 @@ +--TEST-- +bug 51192, FILTER_VALIDATE_URL will invalidate a hostname that includes '-' +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> +--FILE-- +<?php +var_dump(filter_var('http://example.com/path', FILTER_VALIDATE_URL)); +var_dump(filter_var('http://exa-mple.com/path', FILTER_VALIDATE_URL)); +var_dump(filter_var('http://exa_mple.com/path', FILTER_VALIDATE_URL)); +--EXPECT-- +string(23) "http://example.com/path" +string(24) "http://exa-mple.com/path" +bool(false) Modified: php/php-src/branches/PHP_5_3/ext/filter/logical_filters.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/filter/logical_filters.c 2010-03-03 06:31:15 UTC (rev 295772) +++ php/php-src/branches/PHP_5_3/ext/filter/logical_filters.c 2010-03-03 09:25:50 UTC (rev 295773) @@ -467,7 +467,7 @@ s = url->host; while (s < e) { - if (!isalnum((int)*(unsigned char *)s) && *s != '_' && *s != '.') { + if (!isalnum((int)*(unsigned char *)s) && *s != '-' && *s != '.') { goto bad_url; } s++; Added: php/php-src/branches/PHP_5_3/ext/filter/tests/bug51192.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/filter/tests/bug51192.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/filter/tests/bug51192.phpt 2010-03-03 09:25:50 UTC (rev 295773) @@ -0,0 +1,13 @@ +--TEST-- +bug 51192, FILTER_VALIDATE_URL will invalidate a hostname that includes '-' +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> +--FILE-- +<?php +var_dump(filter_var('http://example.com/path', FILTER_VALIDATE_URL)); +var_dump(filter_var('http://exa-mple.com/path', FILTER_VALIDATE_URL)); +var_dump(filter_var('http://exa_mple.com/path', FILTER_VALIDATE_URL)); +--EXPECT-- +string(23) "http://example.com/path" +string(24) "http://exa-mple.com/path" +bool(false) Modified: php/php-src/trunk/ext/filter/logical_filters.c =================================================================== --- php/php-src/trunk/ext/filter/logical_filters.c 2010-03-03 06:31:15 UTC (rev 295772) +++ php/php-src/trunk/ext/filter/logical_filters.c 2010-03-03 09:25:50 UTC (rev 295773) @@ -467,7 +467,7 @@ s = url->host; while (s < e) { - if (!isalnum((int)*(unsigned char *)s) && *s != '_' && *s != '.') { + if (!isalnum((int)*(unsigned char *)s) && *s != '-' && *s != '.') { goto bad_url; } s++; Added: php/php-src/trunk/ext/filter/tests/bug51192.phpt =================================================================== --- php/php-src/trunk/ext/filter/tests/bug51192.phpt (rev 0) +++ php/php-src/trunk/ext/filter/tests/bug51192.phpt 2010-03-03 09:25:50 UTC (rev 295773) @@ -0,0 +1,13 @@ +--TEST-- +bug 51192, FILTER_VALIDATE_URL will invalidate a hostname that includes '-' +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip"); ?> +--FILE-- +<?php +var_dump(filter_var('http://example.com/path', FILTER_VALIDATE_URL)); +var_dump(filter_var('http://exa-mple.com/path', FILTER_VALIDATE_URL)); +var_dump(filter_var('http://exa_mple.com/path', FILTER_VALIDATE_URL)); +--EXPECT-- +string(23) "http://example.com/path" +string(24) "http://exa-mple.com/path" +bool(false)
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php