Problem/Motivation
Internationalizing Domain Names in Applications (IDNA) is a mechanism that has been around for a few years now and is based on multiple RFCs to allow the usage of domain names containing non-ASCII characters.
Relevant RFCs are the following (taken from https://uasg.tech):
Internationalized Domain Names for Applications (IDNA):Definitions and Document Framework
https://tools.ietf.org/html/rfc5890
Internationalized Domain Names in Applications (IDNA): Protocol
https://tools.ietf.org/html/rfc5891
The Unicode Code Points andInternationalized Domain Names for Applications (IDNA)
https://tools.ietf.org/html/rfc5892
Right-to-Left Scripts forInternationalized Domain Names for Applications (IDNA)
https://tools.ietf.org/html/rfc5893
Internationalized Domain Names for Applications (IDNA): Background, Explanation, and Rationale
https://tools.ietf.org/html/rfc5894
Mapping Characters forInternationalized Domain Names in Applications (IDNA) 2008
https://tools.ietf.org/html/rfc5895
Drupal 7 && Drupal 8/9
The current implementation of Drupal's URL syntax verifier valid_url() / UrlHelper::isValid() does only support 5 out of 19 examples for Internationalized Domain Names defined by the Universal Acceptance Steering Group (https://uasg.tech/).
Drupal 9
Although we are already shipping with the Symfony Url constraint which supports all these cases, we are still using a custom implementation that fails in many valid cases.
Example internationalized domain names and the validity in D7/D8:
| Structure | Status D7 | Status D8 | Example |
| Ascii.new | ok | ok | https://ua-test.link |
| Ascii.long | ok | ok | https://ua-test.technology |
| Idn.ascii | fail | fail | https://普遍接受-测试.top |
| Ascii.idn | fail | fail | https://ua-test.世界 |
| Idn.idn | fail | fail | https://普遍接受-测试.世界 |
| Idn-open dot-idn | fail | fail | https://普遍接受-测试。世界 |
| Ascii.punycode | ok | ok | https://ua-test.xn--rhqv96g |
| Punycode.ascii | ok | ok | https://xn----f38am99bqvcd5liy1cxsg.top |
| Punycode.punycode | ok | ok | https://xn----f38am99bqvcd5liy1cxsg.xn--rhqv96g |
| RTL.ascii | fail | fail | https://اختبار-القبولالعالمي.top |
| RTL.RTL | fail | fail | اختبار-القبولالعالمي.شبكةhttps:// |
| Ascii.new/Unicode | fail | fail | https://ua-test.link/我的页面 |
| Ascii.long/Unicode | fail | fail | https://ua-test.technology/我的页面 |
| Idn.ascii/Unicode | fail | fail | https://普遍接受-测试.top/我的页面 |
| Ascii.idn/Unicode | fail | fail | https://ua-test.世界/我的页面 |
| Idn.idn/Unicode | fail | fail | https://普遍接受-测试.世界/我的页面 |
| Idn-opendot-idn/unicode | fail | fail | https://普遍接受-测试。世界/我的页面 |
| RTL.ascii/Unicode | fail | fail | https://ختبار-القبولالعالمي.top/我的页面 |
| RTL.RTL/Unicode | fail | fail | https://اختبار-القبولالعالمي.شبكة/我的页面 |
References:
https://tools.ietf.org/html/rfc3986
https://uasg.tech/
https://en.wikipedia.org/wiki/Internationalized_domain_name
https://www.icann.org/resources/pages/idn-2012-02-25-en
https://bgp.he.net/report/dns#_alltlds
Proposed resolution
Drupal 9
* Use Symfony's Url Constraint for validation.
Drupal 7
@todo
Remaining tasks
Drupal 9
- Patch Drupal core to use Symfony's Url Constraint
- Review
- Create release notes snippet
Drupal 7
@todo
User interface changes
none
API changes
none
Data model changes
none
Release notes snippet
Original report by [username]
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | 3045484-nr-bot.txt | 146 bytes | needs-review-queue-bot |
| #13 | 3045484-12.patch | 7.97 KB | quietone |
| #13 | interdiff-11-12.txt | 5.27 KB | quietone |
| #12 | 3045484-12.patch | 8.22 KB | quietone |
| #12 | interdiff-11-12.txt | 455 bytes | quietone |
Comments
Comment #2
sanduhrsPatch attached, please review.
Comment #3
sanduhrsComment #4
sanduhrsComment #8
quietone commentedAh, nice an issue that does use Symfony for Url validation.
Rerolled for 9.2.x and modified the test so that :// wasn't always prepended to the Url being tested. The list of Urls needs some work to organize with cSpell disable/enable.
Comment #11
quietone commentedLet's see if adding a NotBlank validator to the Url validation fixes the tests.
Comment #12
quietone commentedYes, still forget to run commit-code-check.
Comment #13
quietone commentedClean up of the cSpell: disable/enable and modify UrlHelper to use the $allowedProtocols.
Comment #14
quietone commentedI could be wrong but this doesn't fit the criteria for a bug, so changing to feature request.
Comment #15
quietone commentedComment #20
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.