:idna can't decode some valid domain names

When I try to use :idna library to decode some totally valid domain names I receive error: {:bad_label, {:nfc, ‘Label must be in Normalization Form C’}}. Though chrome and various online punycode decoders can decode it just fine.
Such domain names (in punycode) are: xn–0pdb6zva23bc, xn–1pdyzura42bpa, কোম্পানি.ভারত.

iex(5)> :idna.decode('xn--0pdb6zva23bc')
** (exit) {:bad_label, {:nfc, 'Label must be in Normalization Form C'}}
    (idna 6.1.1) /deps/idna/src/idna.erl:157: :idna.check_nfc/1
    (idna 6.1.1) /deps/idna/src/idna.erl:255: :idna.check_label/4
    (idna 6.1.1) /deps/idna/src/idna.erl:313: :idna.ulabel/1
    (idna 6.1.1) /deps/idna/src/idna.erl:296: :idna.decode_1/2
1 Like

According to the readme, :idna follows RFC5891 which states:

Registration processes, especially processing by entities (often called “registrars”) who deal with registrants before the request actually reaches the zone manager (“registry”) are outside the scope of this definition and may differ significantly depending on local needs. By the time a string enters the IDNA registration process as described in this specification, it MUST be in Unicode and in Normalization Form C (NFC [Unicode-UAX15]). Entities responsible for zone files (“registries”) MUST accept only the exact string for which registration is requested, free of any mappings or local adjustments. They MAY accept that input in any of three forms: 1. As a pair of A-label and U-label. 2. As an A-label only. 3. As a U-label only. The first two of these forms are RECOMMENDED because the use of A-labels avoids any possibility of ambiguity. The first is normally preferred over the second because it permits further verification of user intent (see Section 4.2.1).

It would seem :idna follows the RFC correctly whereas in the wild, this is not fully complied with (not a new situation I appreciate).

Choices would seem limited:

  1. Tell the registrar of the domain that it is not RFC compliant (yeah, I know, unlikely to make a lot of progress)

  2. As @benoit to consider a flag omitting the NFC check (I think it probably should be NFKC but thats a niggle)

  3. Fork the source and make the change you need

1 Like