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
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/).
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
Use Symfony’s URL constraint for absolute URL validation.
Preserve existing supported schemes, single-label hosts, rejection of empty values, and relative URL validation.
Preserve accepted percent-encoded UTF-8 hostnames, including `https://caf%C3%A9.example.org`.
URL syntax validation and complete IDNA conformance are separate concerns. Define handling of Unicode dot separators explicitly.
Remaining tasks
- Update the implementation for `main`.
- Restore disabled compatibility tests.
- Resolve percent-encoded hostname handling.
- Add named tests for Unicode domains, punycode, RTL domains, Unicode paths, and malformed input.
- Verify standalone component dependencies.
- Run automated tests and commit checks.
- Review and document compatibility changes.
User interface changes
none
API changes
No signature changes.
Accepted input expands.
Data model changes
none
Release notes snippet
Original report by [username]
| Comment | File | Size | Author |
|---|
Issue fork drupal-3045484
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3045484-idn-support
changes, plain diff MR !17403
- 3045484-add-support-for
compare
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.
Comment #23
claudiu.cristeaComment #26
sanduhrsRe-rolled the patch for main.
Comment #27
sanduhrsComment #28
sanduhrsI think this is complete, anyone up for review?
Comment #29
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #30
sanduhrsRebased onto current main and resolved a Composer conflict, keeping main’s newer masterminds/html5 requirement.
Comment #31
quietone commentedRebased and test the commented out cases and found that some are passing now. So, adjusted the test accordingly.