Bug #64948 [Opn]: FILTER_VALIDATE_URL does not see urls with underscores as valid URLs.
| From: | yohgaki@php.net | Date: | Wed, 17 Oct 2018 03:17:54 +0000 |
| Subject: | Bug #64948 [Opn]: FILTER_VALIDATE_URL does not see urls with underscores as valid URLs. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-217601@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64948&edit=1
ID: 64948
Updated by: yohgaki@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: 7.2
Block user comment: N
Private report: N
New Comment:
Hostname shouldn't have "_".
However, NETBIOS allows "_" in hostname. DomainKeys/etc use "_" to distinguish
service name and hostname.
This isn't a bug, but feature request for additional option like
FILTER_VALIDATE_URL_WITH_UNDERSCORE or FILTER_VALIDATE_SERVICE_URL.
Previous Comments:
------------------------------------------------------------------------
[2018-10-16 16:05:20] spam2 at rhsoft dot net
yeah they are somehow supported
then get MSIE and try to verify a web-app working on it too you developed with chrome/firefox and
wonder about all sorts of randomly lost cookies and session errors
my co-worker repeatly wasted hours by add a hostname with underscore to /etc/hosts on his
development machine and then searching issues which would not have happened by follow RFC's
just becaus some fools ignore RFCs makes it not a good idea to follow
------------------------------------------------------------------------
[2018-10-16 16:02:42] requinix@php.net
That URL clearly shows that underscores are supported. At least in my browser. Whether RFCs
technically allow for it or not is besides the point now.
I think FILTER_VALIDATE_URL should allow underscores.
------------------------------------------------------------------------
[2018-10-16 09:34:20] spam2 at rhsoft dot net
so blame that fool, even wikipedia knows
https://en.wikipedia.org/wiki/Hostname
The Internet standards (Requests for Comments) for protocols mandate that component hostname labels
may contain only the ASCII letters 'a' through 'z' (in a case-insensitive
manner), the digits '0' through '9', and the minus sign ('-'). The
original specification of hostnames in RFC 952, mandated that labels could not start with a digit or
with a minus sign, and must not end with a minus sign. However, a subsequent specification (RFC
1123) permitted hostname labels to start with digits. No other symbols, punctuation characters, or
white space are permitted.
While a hostname may not contain other characters, such as the underscore character (_), other DNS
names may contain the underscore.[4][5] Systems such as DomainKeys and service records use the
underscore as a means to assure that their special character is not confused with hostnames
------------------------------------------------------------------------
[2018-10-16 09:29:34] luke at reviews dot co dot uk
As requested, the below URL is what caused me to stumble across this "bug"
https://electrictobacconist_co_uk.secure-cdn.visualsoft.co.uk/images/gamucci-refills-p86-15678_image.jpg
------------------------------------------------------------------------
[2018-10-15 16:31:59] requinix@php.net
@neclimdul: You're looking at RFC 2396 which was obsoleted by RFC 3986. If you look there
you'll see the grammar still allows it, however it comes with a caveat:
> A registered name intended for lookup in the DNS uses the syntax defined in
> Section 3.5 of [RFC1034] and Section 2.1 of [RFC1123].
As has been said, the situation for underscores is complicated and somewhat contradictory, both for
URIs and for DNS. Some RFCs allow them and others do not. I'd give a primer but we're
talking about more than just a couple RFCs involved in this. Basically, URIs allow underscores in
hostnames by way of the grammar but with the caveat I mentioned above, DNS as a whole does not allow
it for labels according to that grammar, yet some DNS record types do allow them (notably SRV and
TXT).
But remember here we're specifically talking about URLs.
Can anyone link a functioning *website* that uses an underscore in the domain name? I'm
thinking we tie the status of this request to that: if there is one and it works in browsers then we
allow underscores, otherwise not.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=64948
--
Edit this bug report at https://bugs.php.net/bug.php?id=64948&edit=1