Bug #54255 [NEW]: FILTER_VALIDATE_URL does not allow - in domain name

From: Date: Tue, 15 Mar 2011 08:56:49 +0000
Subject: Bug #54255 [NEW]: FILTER_VALIDATE_URL does not allow - in domain name
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-159485@lists.php.net to get a copy of this message
From:             
Operating system: Linux
PHP version:      5.3.5
Package:          Filter related
Bug Type:         Bug
Bug description:FILTER_VALIDATE_URL does not allow - in domain name

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 bug report at http://bugs.php.net/bug.php?id=54255&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=54255&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=54255&r=trysnapshot53
Try a snapshot (trunk):              http://bugs.php.net/fix.php?id=54255&r=trysnapshottrunk
Fixed in SVN:                        http://bugs.php.net/fix.php?id=54255&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54255&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=54255&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=54255&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=54255&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=54255&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=54255&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=54255&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=54255&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=54255&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=54255&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=54255&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=54255&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=54255&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=54255&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=54255&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=54255&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=54255&r=mysqlcfg



Thread (7 messages)

« previous php.bugs (#159485) next »