Return-Path: Delivered-To: apmail-abdera-commits-archive@www.apache.org Received: (qmail 52670 invoked from network); 5 Dec 2010 22:51:47 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 5 Dec 2010 22:51:47 -0000 Received: (qmail 67344 invoked by uid 500); 5 Dec 2010 22:51:47 -0000 Delivered-To: apmail-abdera-commits-archive@abdera.apache.org Received: (qmail 67306 invoked by uid 500); 5 Dec 2010 22:51:46 -0000 Mailing-List: contact commits-help@abdera.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@abdera.apache.org Delivered-To: mailing list commits@abdera.apache.org Received: (qmail 67299 invoked by uid 99); 5 Dec 2010 22:51:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Dec 2010 22:51:46 +0000 X-ASF-Spam-Status: No, hits=-1998.4 required=10.0 tests=ALL_TRUSTED,HTTP_ESCAPED_HOST,NORMAL_HTTP_TO_IP X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Dec 2010 22:51:43 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id CAE422388A2C; Sun, 5 Dec 2010 22:51:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1042481 - in /abdera/java/trunk/dependencies/i18n/src: main/java/org/apache/abdera/i18n/iri/ main/java/org/apache/abdera/i18n/text/ test/java/org/apache/abdera/i18n/test/iri/ Date: Sun, 05 Dec 2010 22:51:21 -0000 To: commits@abdera.apache.org From: ckoppelt@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101205225121.CAE422388A2C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ckoppelt Date: Sun Dec 5 22:51:21 2010 New Revision: 1042481 URL: http://svn.apache.org/viewvc?rev=1042481&view=rev Log: fix for ABDERA-258 Removed: abdera/java/trunk/dependencies/i18n/src/test/java/org/apache/abdera/i18n/test/iri/TestSuite.java Modified: abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/IDNA.java abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/IRI.java abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/text/CharUtils.java abdera/java/trunk/dependencies/i18n/src/test/java/org/apache/abdera/i18n/test/iri/TestIRI.java Modified: abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/IDNA.java URL: http://svn.apache.org/viewvc/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/IDNA.java?rev=1042481&r1=1042480&r2=1042481&view=diff ============================================================================== --- abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/IDNA.java (original) +++ abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/IDNA.java Sun Dec 5 22:51:21 2010 @@ -22,9 +22,9 @@ import java.io.Serializable; import java.net.UnknownHostException; import org.apache.abdera.i18n.text.CharUtils; +import org.apache.abdera.i18n.text.CharUtils.Profile; import org.apache.abdera.i18n.text.Nameprep; import org.apache.abdera.i18n.text.Punycode; -import org.apache.abdera.i18n.text.CharUtils.Profile; /** * Provides an Internationized Domain Name implementation @@ -94,10 +94,12 @@ public final class IDNA implements Seria public static String toASCII(String regname) { try { - if (regname == null) + if (regname == null){ return null; - if (regname.length() == 0) + } + if (regname.length() == 0){ return regname; + } String[] labels = regname.split("\\\u002E"); StringBuilder buf = new StringBuilder(); for (String label : labels) { Modified: abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/IRI.java URL: http://svn.apache.org/viewvc/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/IRI.java?rev=1042481&r1=1042480&r2=1042481&view=diff ============================================================================== --- abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/IRI.java (original) +++ abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/IRI.java Sun Dec 5 22:51:21 2010 @@ -25,11 +25,11 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.abdera.i18n.text.CharUtils; +import org.apache.abdera.i18n.text.CharUtils.Profile; import org.apache.abdera.i18n.text.InvalidCharacterException; import org.apache.abdera.i18n.text.Nameprep; import org.apache.abdera.i18n.text.Normalizer; import org.apache.abdera.i18n.text.UrlEncoding; -import org.apache.abdera.i18n.text.CharUtils.Profile; import org.apache.abdera.i18n.text.data.UnicodeCharacterDatabase; public final class IRI implements Serializable, Cloneable { @@ -121,7 +121,11 @@ public final class IRI implements Serial } private void init() { - a_host = IDNA.toASCII(host); + if (host != null && host.startsWith("[")) { + a_host = host; + } else { + a_host = IDNA.toASCII(host); + } a_fragment = UrlEncoding.encode(fragment, Profile.FRAGMENT.filter()); a_path = UrlEncoding.encode(path, Profile.PATH.filter()); a_query = UrlEncoding.encode(query, Profile.QUERY.filter(), Profile.PATH.filter()); @@ -312,7 +316,8 @@ public final class IRI implements Serial try { return super.clone(); } catch (CloneNotSupportedException e) { - return new IRI(toString()); // not going to happen, but we have to catch it + return new IRI(toString()); // not going to happen, but we have to + // catch it } } @@ -544,7 +549,7 @@ public final class IRI implements Serial } try { CharUtils.verify(userinfo, Profile.IUSERINFO); - CharUtils.verify(host, Profile.IREGNAME); + CharUtils.verify(host, Profile.IHOST); } catch (InvalidCharacterException e) { throw new IRISyntaxException(e); } Modified: abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/text/CharUtils.java URL: http://svn.apache.org/viewvc/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/text/CharUtils.java?rev=1042481&r1=1042480&r2=1042481&view=diff ============================================================================== --- abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/text/CharUtils.java (original) +++ abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/text/CharUtils.java Sun Dec 5 22:51:21 2010 @@ -413,6 +413,10 @@ public final class CharUtils { public static boolean isAlphaDigit(int codepoint) { return isDigit(codepoint) || isAlpha(codepoint); } + + public static boolean isHex (int codepoint){ + return isDigit(codepoint) || CharUtils.inRange(codepoint, 'a', 'f') || CharUtils.inRange(codepoint, 'A', 'F'); + } /** * True if the codepoint is a bidi control character @@ -538,6 +542,10 @@ public final class CharUtils { public boolean accept(int codepoint) { return !is_iregname(codepoint); } + }), IHOST (new Filter(){ + public boolean accept(int codepoint){ + return !is_ihost(codepoint); + } }), IPRIVATE(new Filter() { public boolean accept(int codepoint) { return !is_iprivate(codepoint); @@ -764,6 +772,16 @@ public final class CharUtils { || codepoint == '=' || codepoint == '"'; } + + public static boolean is_ipliteral (int codepoint){ + return isHex(codepoint) || codepoint==':' + || codepoint =='[' + || codepoint==']'; + } + + public static boolean is_ihost (int codepoint){ + return is_iregname(codepoint) || is_ipliteral(codepoint); + } public static boolean is_regname(int codepoint) { return isUnreserved(codepoint) || codepoint == '!' Modified: abdera/java/trunk/dependencies/i18n/src/test/java/org/apache/abdera/i18n/test/iri/TestIRI.java URL: http://svn.apache.org/viewvc/abdera/java/trunk/dependencies/i18n/src/test/java/org/apache/abdera/i18n/test/iri/TestIRI.java?rev=1042481&r1=1042480&r2=1042481&view=diff ============================================================================== --- abdera/java/trunk/dependencies/i18n/src/test/java/org/apache/abdera/i18n/test/iri/TestIRI.java (original) +++ abdera/java/trunk/dependencies/i18n/src/test/java/org/apache/abdera/i18n/test/iri/TestIRI.java Sun Dec 5 22:51:21 2010 @@ -22,6 +22,7 @@ import static org.junit.Assert.assertTru import static org.junit.Assert.assertFalse; import java.net.URI; +import java.net.URISyntaxException; import org.apache.abdera.i18n.iri.IRI; import org.apache.abdera.i18n.text.Normalizer; @@ -36,6 +37,24 @@ public class TestIRI extends TestBase { assertEquals("http://validator.w3.org/check?uri=http%3A%2F%2Fr%C3%A9sum%C3%A9.example.org", iri.toURI() .toString()); } + + @Test + public void testIpv4() throws URISyntaxException{ + IRI iri = new IRI("http://127.0.0.1"); + assertEquals("http://127.0.0.1", iri.toURI().toString()); + } + + @Test + public void testIpv6() throws URISyntaxException{ + IRI iri = new IRI("http://[2001:0db8:85a3:08d3:1319:8a2e:0370:7344]"); + assertEquals("http://[2001:0db8:85a3:08d3:1319:8a2e:0370:7344]", iri.toURI().toString()); + } + + @Test(expected=URISyntaxException.class) + public void testIpv6Invalid() throws URISyntaxException{ + IRI iri = new IRI("http://[2001:0db8:85a3:08d3:1319:8a2e:0370:734o]"); + iri.toURI().toString(); + } @Test public void testFile() throws Exception {