Edit report at http://bugs.php.net/bug.php?id=54255&edit=1
ID: 54255 Updated by: [email protected] Reported by: nm at web dot am Summary: FILTER_VALIDATE_URL does not allow - in domain name Status: Bogus Type: Bug Package: Filter related Operating System: Linux PHP Version: 5.3.5 Block user comment: N Private report: N New Comment: Oh, and: # php -r 'var_dump(filter_var("http://ea_sd.com", FILTER_VALIDATE_URL));' bool(false) Previous Comments: ------------------------------------------------------------------------ [2011-03-15 15:38:21] [email protected] # php -v PHP 5.3.5 (cli) (built: Mar 15 2011 07:36:59) # php -r 'var_dump(filter_var("http://ea-sd.com", FILTER_VALIDATE_URL));' string(16) "http://ea-sd.com" ------------------------------------------------------------------------ [2011-03-15 09:56:49] nm at web dot am Description: ------------ FILTER_VALIDATE_URL documentatin says that it does filtering according to rfc2396, but in fact filter_var fails to conform RFC. Hostname definition in rfc is as follows: hostport = host [ ":" port ] host = hostname | IPv4address hostname = *( domainlabel "." ) toplabel [ "." ] domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum toplabel = alpha | alpha *( alphanum | "-" ) alphanum so it should allow "-" dash symbol in domainnames (both domain name and TLD name). In other hand it SHOULD NOT allow "_" symbol in the domain name, as it is against specification (right now it allows). Test script: --------------- first case also should validate successfully php -r 'var_dump(filter_var("http://ea-sd.com", FILTER_VALIDATE_URL));' bool(false) php -r 'var_dump(filter_var("http://easd.com", FILTER_VALIDATE_URL));' string(15) "http://easd.com" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54255&edit=1
