Edit report at https://bugs.php.net/bug.php?id=64948&edit=1

 ID:                 64948
 Updated by:         ahar...@php.net
 Reported by:        neclimdul at gmail dot com
 Summary:            FILTER_VALIDATE_URL does not see urls with
                     underscores as valid URLs.
 Status:             Open
 Type:               Bug
 Package:            Filter related
 Operating System:   Ubuntu
 PHP Version:        5.4.15
 Block user comment: N
 Private report:     N

 New Comment:

This is a tricky one. I think the current behaviour is technically correct 
here, 
but I don't particularly want to summarily close this either.

Technically speaking, host names can't include underscores. 
http://stackoverflow.com/a/2183140 links to the various RFCs that define this 
— 
domain names (such as those used in SRV records) can contain underscores, but 
host names have a more restrictive character set.

That said, RFC 3986 (which is presumably what a URL validation routine is 
ultimately beholden to) is specified more loosely to cover non-DNS name 
registries. Hosts are reg-name elements there, which allows percent encoded 
characters, hyphens, dots, underscores, tildes, and a range of characters 
defined as sub-delims.

Given that underscores do have implementation issues in the wild (IE's cookie 
issues, for instance), my inclination is to leave this, as I said at the start, 
but I'd like a second opinion.

tl;dr: RFC lawyer material; probably Won't Fix; need a second opinion.


Previous Comments:
------------------------------------------------------------------------
[2013-05-30 14:59:10] neclimdul at gmail dot com

Description:
------------
FILTER_VALIDATE_URL does not see urls with underscores as valid URLs. 
Underscores 
are however valid and common in urls in the wild.

Test script:
---------------
$url = 'http://foo_bar.example.com';
var_dump(filter_var($url, FILTER_VALIDATE_URL));


Expected result:
----------------
string(26) "http://foo_bar.example.com";

Actual result:
--------------
bool(false)


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64948&edit=1

Reply via email to