diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2014-05-30 20:19:46 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2014-06-04 13:24:24 +0100 |
commit | eee7189f05ad0de23c4a56ce0255a25d0ee4b4d8 (patch) | |
tree | 6e5a55003cbbd8a2fb7991e88f2a6122b8bb5ed3 /utils | |
parent | db0856606a7f2da053a2a7ff2cee12b69d23cb52 (diff) | |
download | netsurf-eee7189f05ad0de23c4a56ce0255a25d0ee4b4d8.tar.gz netsurf-eee7189f05ad0de23c4a56ce0255a25d0ee4b4d8.tar.bz2 |
Normalise intermediary UCS-4 string when verifying ACE labels
Diffstat (limited to 'utils')
-rw-r--r-- | utils/idna.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/utils/idna.c b/utils/idna.c index 826d041fb..5ec05e612 100644 --- a/utils/idna.c +++ b/utils/idna.c @@ -487,15 +487,23 @@ static bool idna__verify(const char *label, size_t len) char *ace; size_t ucs4_len, ace_len; + /* Convert our ACE label back to UCS-4 */ error = idna__ace_to_ucs4(label, len, &ucs4, &ucs4_len); if (error != NSERROR_OK) return false; + /* Perform NFC normalisation */ + ucs4_len = utf8proc_normalise(ucs4, ucs4_len, + UTF8PROC_STABLE | UTF8PROC_COMPOSE); + if(ucs4_len < 0) return false; + + /* Convert the UCS-4 label back to ACE */ error = idna__ucs4_to_ace(ucs4, ucs4_len, &ace, &ace_len); free(ucs4); if (error != NSERROR_OK) return false; + /* Check if it matches the input */ if ((len == ace_len) && (strncmp(label, ace, len) == 0)) { free(ace); return true; |