diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2014-05-30 20:19:46 +0100 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2014-05-30 20:19:46 +0100 |
commit | 4a654e59bab006e35a2e9ac6af0cf85e411fd758 (patch) | |
tree | f83ecbf25b2fc6d81e8eb367bb437308b1de5cba | |
parent | 38c8a97da029d50f053f4ab91b19e49d6c4c24c8 (diff) | |
download | netsurf-chris/idna2008.tar.gz |
Normalise intermediary UCS-4 string when verifying ACE labelschris/idna2008
-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; |