diff options
-rw-r--r-- | src/com/isode/stroke/idn/IDNA.java | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/com/isode/stroke/idn/IDNA.java b/src/com/isode/stroke/idn/IDNA.java index e3b86dd..653a2d2 100644 --- a/src/com/isode/stroke/idn/IDNA.java +++ b/src/com/isode/stroke/idn/IDNA.java @@ -4,7 +4,7 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ /* - * Copyright (c) 2011, Isode Limited, London, England. + * Copyright (c) 2011-2015, Isode Limited, London, England. * All rights reserved. */ package com.isode.stroke.idn; @@ -13,11 +13,16 @@ import java.net.IDN; public class IDNA { public static String getEncoded(String s) { - try { - return IDN.toASCII(s, IDN.USE_STD3_ASCII_RULES); + try { + return IDN.toASCII(s, IDN.USE_STD3_ASCII_RULES); + } + catch (IllegalArgumentException e) { + return null; + } + catch (StringIndexOutOfBoundsException e) { + // In java 7 IDN.toASCII sometimes throws StringIndexOutOfBoundException + // (instead of IllegalArgumentException) + return null; } - catch (IllegalArgumentException e) { - return null; - } } } |