You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@abdera.apache.org by jm...@apache.org on 2006/10/02 20:42:32 UTC
svn commit: r452169 - in /incubator/abdera/java/trunk/core/src:
main/java/org/apache/abdera/util/io/ main/java/org/apache/abdera/util/iri/
test/java/org/apache/abdera/test/iri/
Author: jmsnell
Date: Mon Oct 2 11:42:31 2006
New Revision: 452169
URL: http://svn.apache.org/viewvc?view=rev&rev=452169
Log:
Ok, *hopefully* this will fix the issues Ugo and Garrett are seeing with the IRI code. Please test
and let me know.
Modified:
incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/io/CharUtils.java
incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/Escaping.java
incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/IRI.java
incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/iri/TestIRI.java
Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/io/CharUtils.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/io/CharUtils.java?view=diff&rev=452169&r1=452168&r2=452169
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/io/CharUtils.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/io/CharUtils.java Mon Oct 2 11:42:31 2006
@@ -26,6 +26,10 @@
private CharUtils() {}
+ public static boolean isValidCodepoint(int d) {
+ return d >= 0x000000 && d <= 0x10ffff;
+ }
+
public static int scanNot(CodepointIterator ci, BitSet set) throws InvalidCharacterException {
RestrictedCodepointIterator rci = new RestrictedCodepointIterator(ci,set,true,true);
while (rci.hasNext()) rci.next();
Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/Escaping.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/Escaping.java?view=diff&rev=452169&r1=452168&r2=452169
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/Escaping.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/Escaping.java Mon Oct 2 11:42:31 2006
@@ -81,7 +81,7 @@
public static String decode(String e, String enc)
throws UnsupportedEncodingException {
- DecodingReader r = new DecodingReader(e.getBytes(),enc);
+ DecodingReader r = new DecodingReader(e.getBytes(enc),enc);
char[] buf = new char[e.length()];
try {
int l = r.read(buf);
@@ -91,19 +91,16 @@
}
public static String decode(String e) {
- if (e == null) return null;
- DecodingReader r = new DecodingReader(e.getBytes());
- char[] buf = new char[e.length()];
try {
- int l = r.read(buf);
- e = new String(buf,0,l);
- } catch (Exception ex) {}
- return e;
+ return decode(e,"utf-8");
+ } catch (Exception ex) {
+ return e;
+ }
}
public static class DecodingInputStream
extends ByteArrayInputStream {
-
+
DecodingInputStream(byte[] buf) {
super(buf);
}
Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/IRI.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/IRI.java?view=diff&rev=452169&r1=452168&r2=452169
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/IRI.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/IRI.java Mon Oct 2 11:42:31 2006
@@ -19,6 +19,7 @@
import java.io.IOException;
import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.util.BitSet;
@@ -73,6 +74,15 @@
Constants.RESERVED,
Constants.PCTENC,
Constants.GENDELIMS));
+ }
+
+ public IRI(java.net.URI uri, String enc) throws IRISyntaxException, UnsupportedEncodingException {
+ this(Escaping.encode(
+ Escaping.decode(uri.toString(),enc), enc,
+ Constants.IUNRESERVED,
+ Constants.RESERVED,
+ Constants.PCTENC,
+ Constants.GENDELIMS));
}
public IRI(String iri) throws IRISyntaxException {
Modified: incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/iri/TestIRI.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/iri/TestIRI.java?view=diff&rev=452169&r1=452168&r2=452169
==============================================================================
--- incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/iri/TestIRI.java (original)
+++ incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/iri/TestIRI.java Mon Oct 2 11:42:31 2006
@@ -29,7 +29,7 @@
public static void testSimple() throws Exception {
IRI iri = new IRI("http://validator.w3.org/check?uri=http%3A%2F%2Fr\u00E9sum\u00E9.example.org");
- assertEquals(iri.toString(),"http://validator.w3.org/check?uri=http%3A%2F%2Frésumé.example.org");
+ assertEquals(iri.toString(),"http://validator.w3.org/check?uri=http%3A%2F%2Fr\u00E9sum\u00E9.example.org");
assertEquals(iri.toURI().toString(),"http://validator.w3.org/check?uri=http://r%C3%A9sum%C3%A9.example.org");
}
@@ -52,8 +52,8 @@
public static void testURItoIRI2() throws Exception {
URI uri = new URI("http://www.example.org/D%FCrst");
- IRI iri = new IRI(uri);
- assertEquals(iri.toString(),"http://www.example.org/D%FCrst");
+ IRI iri = new IRI(uri, "windows-1252");
+ assertEquals(iri.toString(),"http://www.example.org/D\u00FCrst");
}
public static void testURItoIRI3() throws Exception {
@@ -117,11 +117,6 @@
assertTrue(iri1.equivalent(iri2));
}
- public static void testMixedEncodings() throws Exception {
- IRI iri = new IRI("http://www.example.org/r%E9sum%E9.xml#r%C3%A9sum%C3%A9");
- assertEquals(iri.normalize().toString(),"http://www.example.org/r%E9sum%E9.xml#r\u00E9sum\u00E9");
- }
-
public static void testRelative() throws Exception{
IRI base = new IRI("http://example.org/foo/");
@@ -136,7 +131,4 @@
assertEquals(base.resolve(".").toString(),"http://example.org/foo/");
}
-
-
-
}
Re: svn commit: r452169 - in /incubator/abdera/java/trunk/core/src: main/java/org/apache/abdera/util/io/ main/java/org/apache/abdera/util/iri/ test/java/org/apache/abdera/test/iri/
Posted by Ugo Cei <ug...@gmail.com>.
On Oct 2, 2006, at 9:02 PM, James M Snell wrote:
> Done!
You'l have to close it yourself. Even if I'm the reporter, I don't
seem to have the necessary privilege to do it myself. Strange policy.
Ugo
Re: svn commit: r452169 - in /incubator/abdera/java/trunk/core/src:
main/java/org/apache/abdera/util/io/ main/java/org/apache/abdera/util/iri/
test/java/org/apache/abdera/test/iri/
Posted by James M Snell <ja...@gmail.com>.
Done!
Ugo Cei wrote:
>
> On Oct 2, 2006, at 8:48 PM, Garrett Rooney wrote:
>
>>> Ok, *hopefully* this will fix the issues Ugo and Garrett are seeing
>>> with the IRI code. Please test
>>> and let me know.
>>
>> This fixes the two errors I was seeing. I haven't tried the client
>> tests yet (due to the hanging fun), but other than that everything
>> looks fine to me. Nice work James!
>
> Nice work indeed. All IRI tests now run fine on my OS X. If you resolve
> the issue, I will close it.
>
> Ugo
>
>
Re: svn commit: r452169 - in /incubator/abdera/java/trunk/core/src: main/java/org/apache/abdera/util/io/ main/java/org/apache/abdera/util/iri/ test/java/org/apache/abdera/test/iri/
Posted by Ugo Cei <ug...@gmail.com>.
On Oct 2, 2006, at 8:48 PM, Garrett Rooney wrote:
>> Ok, *hopefully* this will fix the issues Ugo and Garrett are
>> seeing with the IRI code. Please test
>> and let me know.
>
> This fixes the two errors I was seeing. I haven't tried the client
> tests yet (due to the hanging fun), but other than that everything
> looks fine to me. Nice work James!
Nice work indeed. All IRI tests now run fine on my OS X. If you
resolve the issue, I will close it.
Ugo
Re: svn commit: r452169 - in /incubator/abdera/java/trunk/core/src: main/java/org/apache/abdera/util/io/ main/java/org/apache/abdera/util/iri/ test/java/org/apache/abdera/test/iri/
Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 10/2/06, jmsnell@apache.org <jm...@apache.org> wrote:
> Author: jmsnell
> Date: Mon Oct 2 11:42:31 2006
> New Revision: 452169
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=452169
> Log:
> Ok, *hopefully* this will fix the issues Ugo and Garrett are seeing with the IRI code. Please test
> and let me know.
This fixes the two errors I was seeing. I haven't tried the client
tests yet (due to the hanging fun), but other than that everything
looks fine to me. Nice work James!
-garrett