kittinunf / fuel

The easiest HTTP networking library for Kotlin/Android

Home Page:https://fuel.gitbook.io/documentation/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for IDNA 2008 (RFC 5891)

j-bernard opened this issue · comments

The tests have been conducted on Android SDK 30 with Fuel version 2.3.1.

With Fuel, URLs containing Unicode characters are converted using percent encoding but domain names should be converted as defined in RFC 5891.

On Android, the stack does it jobs and correctly performs IDNA conversion, replacing the percent encoding, but it follows an old standard IDNA 2003 (RFC 3490).

To be fully compliant, fuel should perform domain name conversion following IDNA 2008 standard.

This snippet does the conversion from U-label to A-label which is the form that should be provided to the network stack:

val idna = IDNA.getUTS46Instance(flags)
val info = IDNA.Info()
val sb = StringBuilder()
val domainAscii = idna.nameToASCII(domain, sb, info)
// check error with info.hasErrors()

Thanks for filing the issue! Do you think you can try to take a stab and open a PR to support this? Otherwise, I can try to see how to fix this later at the end of the week or something.

I'll try to spend some time on it, maybe next week.