Enabling IDN via macOS/iOS DNS services#13233
Conversation
If no IDN2 library available and no Windows, we can leverage the resolving of UTF-8 encoded domains by macOS/iOS network services.
| result = win32_idn_to_ascii(input, &decoded); | ||
| #elif defined(HAVE_NETDB_H) && defined(__APPLE__) | ||
| /* let MacOS/iOS do this as part of DNS service */ | ||
| struct hostent *p = gethostbyname(input); |
There was a problem hiding this comment.
Perhaps check for HAVE_GETHOSTBYNAME_R or call Curl_ipv4_resolve_r()?
There was a problem hiding this comment.
Well, macOS and iOS have no gethostbyname_r as far as I know.
Calling Curl_ipv4_resolve_r may be a possibility, so we use Curl_getaddrinfo_ex here, which uses getaddrinfo internally, skipping gethostbyname all together.
bagder
left a comment
There was a problem hiding this comment.
What is a little bit scary here is that since this makes a full blown name resolve, this function can take a looong time to completion. Meaning multiple seconds.
This only provides IDN to punycode, not the other way around. So only "half" of the IDN features libcurl uses.
This should probably set the IDN feature in the curl_version_info features?
| decoded = name; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
I see three if() calls that I presume all should set an error code if they fail?
There was a problem hiding this comment.
Maybe worst of all: this requires that the name resolves. It can't convert just an arbitrary host name...!
There was a problem hiding this comment.
Maybe I should add some context. We had clients complaining that domains with umlauts didn't work. libidn isn't preinstalled on macOS or iOS by Apple. And we didn't want to carry the libidn2 library with every app to just get occasionally the domain resolved.
There was a problem hiding this comment.
I understand, but that does not change my comments.
|
Thanks for the feedback. I think we may have something better to suggest in a few days. |
|
See new pr: |
If no IDN2 library available and no Windows, we can leverage the resolving of UTF-8 encoded domains by macOS/iOS network services.
We regularly patch this into new CURL versions and I'd just like to pass it to the source code.
This is a fallback for when building curl for iOS or MacOS without LibIDN2 and still make domains work with umlauts.