Skip to content

Uri - encoding of host should support domain punycoding #60664

Open
@theatischbein

Description

@theatischbein

When parsing an URL as Uri currently dart does not support encoding the domain punycoded, which means certain domains are not reachable without importing third party packages.

Example

  • given URL https://my-äöü-domain.com/endpoint/1234/
  • currently parsed as https://my-%C3%A4%C3%B6%C3%BC-domain.com/endpoint/1234/
  • expected https://xn--my--domain-s5a0tyc.com/endpoint/1234/
void main() {
  final url = "https://my-äöü-domain.com/endpoint/1234/";
  print(url);
  Uri uri = Uri.parse(url);
  print(uri);
}

Real world problem in flutter: https://gitlab.com/TheOneWithTheBraid/dart_pkpass/-/merge_requests/7

Punycode

  • is used to encode Internationalized Domain Names in Applications (IDNA)
  • is a special encoding used to convert Unicode characters to ASCII, which is a smaller, restricted character set.
  • defined in RFC 3492 and RFC 5891

Workarounds

Solution

  • this should be part of the core package / Uri class
  • merge solution like punycode_converter into into Uri -> host

My System

❯ dart info

#### General info

- Dart 3.5.4 (stable) (Wed Oct 16 16:18:51 2024 +0000) on "linux_x64"
- on linux / Linux 6.14.4-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 26 Apr 2025 00:06:37 +0000
- locale is en_GB.UTF-8

#### Process info

| Memory |  CPU | Elapsed time | Command line                        |
| -----: | ---: | -----------: | ----------------------------------- |
| 385 MB | 0.7% |        20:47 | dart language-server --protocol=lsp |

Metadata

Metadata

Assignees

Labels

area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.library-coretype-enhancementA request for a change that isn't a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions