The idna.Registration.ToASCII function only validates that a domain name
can be registered in the sense that it is syntactically valid; not that it
makes sense semantically including that the TLD is valid. You can pass it
the string "a" and it will return that string without error. Its purpose is
to rewrite a domain name containing non-ASCII characters into one which
only contains ASCII chars in accordance with the IDNA standard. Which means
a domain name like "100.100.100.100" is no different than "a.b.c.d" as far
as idna.Registration.ToASCII() is concerned.

On Sun, Nov 13, 2022 at 9:20 PM redder <justma...@gmail.com> wrote:

> I suspected this to be the case but wasn't completely sure. Thank you for
> confirming.
>
> Perhaps I don't understand how this function is typically used in
> practice, but to me it seems using Registration.ToASCII() alone is never
> sufficient for registerable domain name validation. In addition to it, one
> should always check if the input was not an IPv4 address to be thorough. Or
> is it expected that typical users of this function will further validate
> the domain name against a whitelist of TLDs, hence making the IPv4 check
> unnecessary?
>
> On Saturday, 12 November 2022 at 21:00:16 UTC-5 kra...@skepticism.us
> wrote:
>
>> I think you've misunderstood the purpose of that package and the relevant
>> standards. An IPv4 address is syntactically a valid domain name and thus no
>> error occurs. The ToASCII conversion is a nop in this case since there are
>> no non-ASCII characters. An IPv6 address is not a syntactically valid
>> domain name so you'll get an error. There is nothing about the conversion
>> process that requires validating whether the TLD (the right-most "100" in
>> your example) is in fact a valid TLD.
>>
>> On Sat, Nov 12, 2022 at 8:22 AM redder <just...@gmail.com> wrote:
>>
>>> https://go.dev/play/p/HdLLJz0uz2q
>>>
>>> idna.Registration.ToASCII("100.100.100.100") doesn't return an error.
>>> Surely an IPv4 address can never be registered as a domain name and so this
>>> should return an error? I just need confirmation: is this function working
>>> as expected or is this a bug?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "golang-nuts" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to golang-nuts...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/golang-nuts/792a7e4a-3335-40c2-8fe9-fca394d2f988n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/golang-nuts/792a7e4a-3335-40c2-8fe9-fca394d2f988n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>>
>> --
>> Kurtis Rader
>> Caretaker of the exceptional canines Junior and Hank
>>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/2689669f-8c62-4f31-9249-f9cc5dd41c69n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/2689669f-8c62-4f31-9249-f9cc5dd41c69n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD_kvPJiESVCNM8MP3pW2J3uqqQbf416y1wA_O31wVtJew%40mail.gmail.com.

Reply via email to