Bug #53474 [Opn]: FILTER_VALIDATE_URL should not fail URL's that use IDN
| From: | cataphract@php.net | Date: | Tue, 07 Dec 2010 00:22:32 +0000 |
| Subject: | Bug #53474 [Opn]: FILTER_VALIDATE_URL should not fail URL's that use IDN | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-156804@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53474&edit=1
ID: 53474
Updated by: cataphract@php.net
Reported by: gunther at keryx dot se
Summary: FILTER_VALIDATE_URL should not fail URL's that use
IDN
Status: Open
Type: Bug
Package: Filter related
Operating System: All
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
IDN refers only to the domain name. http://â¡.ws/䨹
includes also a
non-ascii characters in the path portion.
That part is bogus. http://aaa.ws/䨹 is not a proper
unambiguous URL,
how 䨹 is encoded depends on the encoding (%E4%A8%B9 for UTF-8, but no
standard requires it). As to IDNs, I agree with aharvey, I suppose we
could add a new flag, but the current behavior is not exactly a bug.
This is more a feature request.
Previous Comments:
------------------------------------------------------------------------
[2010-12-06 10:42:45] aharvey@php.net
To be completely clear, filter_var(..., FILTER_VALIDATE_URL) already
handles internationalised domain names in their canonical Punycode
form. I guess what this is really going to boil down to is whether
filter_var() should also support IDN when it's represented in a
Unicode character set, given that's really an intermediate
representation for the user's benefit.
My initial feeling on that is "not by default", but I guess we could
look at a flag for that filter (FILTER_FLAG_IDN_UTF8 or similar) which
enabled support for a particular character set (probably UTF-8).
Thoughts?
------------------------------------------------------------------------
[2010-12-05 21:12:25] gunther at keryx dot se
My initial test was done using PHP 5.3.3
The lack of IDN support is still present in 5.3.3
All of Mathias' additional test cases, but the last one are however
handled correctly. I.e. this one is approved:
http://a.b--c.de/
It should fail. That's probably an edge case, though. The lack of IDN
support is the worst problem.
------------------------------------------------------------------------
[2010-12-05 19:21:14] rasmus@php.net
mathias, you are not testing the current code. Try it with 5.3.3.
------------------------------------------------------------------------
[2010-12-05 10:46:21] mathias at qiwi dot be
I was trying to post a comment here, but it wouldnât let me (âERROR:
Please do not
SPAM our bug systemâ), probably because of all the âURLsâ I was
trying to post.
Oh well, hereâs the comment I tried to post:
http://paste.pocoo.org/raw/VBO3Gn0vIipLQPRIgAEB/
------------------------------------------------------------------------
[2010-12-05 00:28:50] gunther at keryx dot se
Description:
------------
If an URL uses IDN it should be considered valid.
The test script outputs three blank lines. It should output the URL's.
Examples from http://mathiasbynens.be/demo/url-regex
Test script:
---------------
<?php
echo filter_var('http://âªdf.ws/123',
FILTER_VALIDATE_URL);
echo "\n";
echo filter_var('http://â.ws/',
FILTER_VALIDATE_URL);
echo "\n";
echo filter_var('http://â¡.ws/䨹',
FILTER_VALIDATE_URL);
echo "\n";
Expected result:
----------------
http://âªdf.ws/123
http://â.ws/
http://â.ws/http://â¡.ws/䨹
Actual result:
--------------
\n
\n
\n
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53474&edit=1