List of usage examples for org.apache.commons.httpclient.util URIUtil encodeWithinAuthority
public static String encodeWithinAuthority(String unescaped) throws URIException
From source file:pl.nask.hsn2.normalizers.URLNormalizerUtils.java
public static String normalizeUserInfo(StringBuilder in, int start, int end) throws URIException { int endSq = URLNormalizerUtils.findFirstMatch(in, "@", start, end); if (endSq < 0) { endSq = end;//from w w w . ja v a 2 s .c o m } StringBuilder sb = new StringBuilder(in.substring(start, endSq)); int sep = findFirstMatch(sb, ":", 0); String enc = null; if (sep > 0) { removeObfuscatedEncoding(sb, 0, sep, new EncodingType[] { EncodingType.USERINFO }); sep = findFirstMatch(sb, ":", 0); enc = URIUtil.encodeWithinAuthority(sb.substring(0, sep)); sb.replace(0, sep, enc); } else { removeObfuscatedEncoding(sb, new EncodingType[] { EncodingType.USERINFO }); enc = URIUtil.encodeWithinAuthority(sb.toString()); sb.replace(0, sb.length(), enc); } in.replace(start, end, sb.toString()); return sb.toString(); }