Enforce canonicalization of premium/reserved list labels

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=193401336
This commit is contained in:
mcilwain 2018-04-18 12:48:05 -07:00 committed by jianglai
parent c6a4264606
commit 2c0fb6d5a6
7 changed files with 108 additions and 17 deletions

View file

@ -41,7 +41,12 @@ public final class DomainNameUtils {
/** Canonicalizes a domain name by lowercasing and converting unicode to punycode. */
public static String canonicalizeDomainName(String label) {
return Idn.toASCII(Ascii.toLowerCase(label));
String labelLowercased = Ascii.toLowerCase(label);
try {
return Idn.toASCII(labelLowercased);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(String.format("Error ASCIIfying label '%s'", label), e);
}
}
/**