Add IDN support - #986
Conversation
rsync can now connect to IDN (internationalized domain name) hosts, and IDN names are recognized in a daemon's hosts allow/deny.
|
@tridge requesting a review |
steadytao
left a comment
There was a problem hiding this comment.
Apologies, I have been attending to some personal matters recently. This needs careful review against IDNA/punycode behaviour and daemon allow/deny matching semantics before merge. I would want tests covering Unicode input, punycode input, mixed-case hostnames, invalid IDNs and allow/deny matching to make sure this does not widen host access unexpectedly.
|
Tests added |
The IDNA mapping folds some non-ASCII characters onto ASCII ones, so running a whole hosts allow/deny token through idn2_to_ascii_8z() could hand back a pattern the admin never wrote: a "*" (U+FF0A FULLWIDTH ASTERISK) entry came back as "*" and let every host in. Convert label by label instead, keeping an ASCII label byte for byte and using a converted label only when it comes back as a bare A-label. An ASCII-only config now behaves as it did before there was IDN support, and a token that cannot be converted is left alone and so matches nothing. The client side shares the same helper, and neither side truncates a name at its 1024-byte buffer any more. strlower() folds only ASCII now, since its one caller is the hosts allow/deny list, which can hold UTF-8. Adds testsuite/daemon-access-idn and extends testsuite/idn to cover Unicode, punycode, mixed-case and invalid input on both sides.
| label[lablen] = '\0'; | ||
| rc = from_locale | ||
| ? idn2_lookup_ul(label, &idn, IDN2_NONTRANSITIONAL) | ||
| : idn2_to_ascii_8z(label, &idn, IDN2_NFC_INPUT | IDN2_NONTRANSITIONAL); |
There was a problem hiding this comment.
IDN2_NFC_INPUT asserts that this input is already NFC-normalised. We should let libidn2 normalise it and test composed and decomposed equivalents.
There was a problem hiding this comment.
https://gitlab.com/libidn/libidn2
if (nfc && !_isNFC (p, plen))
tmp = u32_normalize (UNINORM_NFC, p, plen, NULL, &tmplen);
nfc is the caller's flags & IDN2_NFC_INPUT. With the flag absent, no normalization runs, and _idn2_label_test(TEST_NFC | ...) then rejects the label:
ok = llen == plen && memcmp (label, p, plen * sizeof (*label)) == 0;
if (!ok) return IDN2_NOT_NFC;
So the flag gates normalization.
The client path called idn2_lookup_ul() without IDN2_NFC_INPUT while the daemon path passed it to idn2_to_ascii_8z(). Both normalize either way -- idn2_lookup_ul() ors the flag in itself, and TR46 normalizes as it maps -- but there is no reason for the two calls to read differently, so pass one set of flags from one place. The flag asks libidn2 to normalize the label rather than promising that it already is: it gates the u32_normalize() call, and without it a decomposed label comes back IDN2_NOT_NFC. Adds composed/decomposed cases to testsuite/idn, which sees the exact host name rsync hands out, and a decomposed hosts allow token to testsuite/daemon-access-idn.
rsync can now connect to IDN (internationalized domain name) hosts, and IDN names are recognized in a daemon's hosts allow/deny.
Closes #851.