Skip to content

Enabling IDN via macOS/iOS DNS services#13233

Closed
MonkeybreadSoftware wants to merge 1 commit into
curl:masterfrom
MonkeybreadSoftware:patch-9
Closed

Enabling IDN via macOS/iOS DNS services#13233
MonkeybreadSoftware wants to merge 1 commit into
curl:masterfrom
MonkeybreadSoftware:patch-9

Conversation

@MonkeybreadSoftware
Copy link
Copy Markdown
Contributor

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.

If no IDN2 library available and no Windows, we can leverage the resolving of UTF-8
encoded domains by macOS/iOS network services.
@github-actions github-actions Bot added the name lookup DNS and related tech label Mar 30, 2024
Comment thread lib/idn.c
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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps check for HAVE_GETHOSTBYNAME_R or call Curl_ipv4_resolve_r()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

@bagder bagder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread lib/idn.c
decoded = name;
}
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see three if() calls that I presume all should set an error code if they fail?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worst of all: this requires that the name resolves. It can't convert just an arbitrary host name...!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand, but that does not change my comments.

@MonkeybreadSoftware
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback. I think we may have something better to suggest in a few days.

@MonkeybreadSoftware
Copy link
Copy Markdown
Contributor Author

See new pr:
#13246

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

name lookup DNS and related tech

Development

Successfully merging this pull request may close these issues.

3 participants