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/03 20:22:11 UTC
svn commit: r452589 - in
/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri:
Constants.java HttpScheme.java IRI.java
Author: jmsnell
Date: Tue Oct 3 11:22:11 2006
New Revision: 452589
URL: http://svn.apache.org/viewvc?view=rev&rev=452589
Log:
Resolution for http://issues.apache.org/jira/browse/ABDERA-9
This is largely a patch up. We will need to revisit this (and the IRI parsing code in general) to ensure
that it can work with as broad a range of IRI/URI schemes as possible.
Modified:
incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/Constants.java
incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/HttpScheme.java
incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/IRI.java
Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/Constants.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/Constants.java?view=diff&rev=452589&r1=452588&r2=452589
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/Constants.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/Constants.java Tue Oct 3 11:22:11 2006
@@ -108,7 +108,10 @@
public final static BitSet IREGNAME = new ChainableBitSet().set2(IUNRESERVED)
.set2(ESCAPED)
- .set2("$,;:@&=+");
+ .set2("!$&'()*+,;=");
+ public final static BitSet REGNAME = new ChainableBitSet().set2(UNRESERVED)
+ .set2(ESCAPED)
+ .set2("!$&'()*+,;=");
public final static BitSet IUSERINFO = new ChainableBitSet().set2(IUNRESERVED)
.set2(ESCAPED)
Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/HttpScheme.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/HttpScheme.java?view=diff&rev=452589&r1=452588&r2=452589
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/HttpScheme.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/iri/HttpScheme.java Tue Oct 3 11:22:11 2006
@@ -79,12 +79,11 @@
ui,
host,
port,
- IRI.normalize(iri.getPath()),
+ IRI.normalize(this,iri.getPath()),
iri.getQuery(),
iri.getFragment(),
iri.doubleslash
);
}
-
}
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=452589&r1=452588&r2=452589
==============================================================================
--- 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 Tue Oct 3 11:22:11 2006
@@ -194,7 +194,7 @@
a_host = IDNA.toASCII(d_host);
a_fragment = Escaping.encode(getFragment(),Constants.FRAGMENT);
- a_path = normalize(Escaping.encode(getPath(), Constants.PATH));
+ a_path = normalize(_scheme,Escaping.encode(getPath(), Constants.PATH));
a_query = Escaping.encode(getQuery(),Constants.QUERY);
a_userinfo = Escaping.encode(getUserInfo(),Constants.USERINFO);
a_authority = buildASCIIAuthority();
@@ -368,12 +368,16 @@
}
private String buildASCIIAuthority() {
- StringBuffer buf = new StringBuffer();
- String aui = getASCIIUserInfo();
- String ah = getASCIIHost();
- int port = getPort();
- buildAuthority(buf,aui,ah,port);
- return buf.toString();
+ if (_scheme instanceof HttpScheme) {
+ StringBuffer buf = new StringBuffer();
+ String aui = getASCIIUserInfo();
+ String ah = getASCIIHost();
+ int port = getPort();
+ buildAuthority(buf,aui,ah,port);
+ return buf.toString();
+ } else {
+ return Escaping.encode(getAuthority(), Constants.USERINFO, Constants.REGNAME);
+ }
}
public String getASCIIAuthority() {
@@ -444,8 +448,8 @@
(b.scheme != null && c.scheme == null) ||
(b.scheme != null && c.scheme != null &&
!b.scheme.equalsIgnoreCase(c.scheme))) return c;
- String bpath = normalize(b.getPath());
- String cpath = normalize(c.getPath());
+ String bpath = normalize(b._scheme,b.getPath());
+ String cpath = normalize(c._scheme,c.getPath());
bpath = (bpath != null) ? bpath : "/";
cpath = (cpath != null) ? cpath : "/";
if (!bpath.equals(cpath)) {
@@ -455,7 +459,7 @@
IRI iri = new IRI(
null,
null,null,null,null,-1,
- normalize(cpath.substring(bpath.length())),
+ normalize(b._scheme,cpath.substring(bpath.length())),
c.getQuery(),
c.getFragment(),
false);
@@ -504,7 +508,7 @@
b.getUserInfo(),
b.getHost(),
b.getPort(),
- normalize(b.getPath()),
+ normalize(b._scheme,b.getPath()),
b.getQuery(),
cfragment,
b.doubleslash
@@ -529,14 +533,14 @@
host = b.getHost();
port = b.getPort();
path = c.isPathAbsolute() ?
- normalize(c.getPath()) :
+ normalize(b._scheme,c.getPath()) :
resolve(b.getPath(),c.getPath());
} else {
authority = c.getAuthority();
userinfo = c.getUserInfo();
host = c.getHost();
port = c.getPort();
- path = normalize(c.getPath());
+ path = normalize(b._scheme,c.getPath());
}
return new IRI(_scheme,scheme,authority,userinfo,host,port,path,query,fragment,ds);
}
@@ -558,14 +562,15 @@
iri.getUserInfo(),
iri.getHost(),
iri.getPort(),
- normalize(iri.getPath()),
+ normalize(iri._scheme,iri.getPath()),
iri.getQuery(),
iri.getFragment(),
iri.doubleslash
);
}
- static String normalize(String path) {
+ static String normalize(Scheme scheme, String path) {
+ if (scheme != null && !(scheme instanceof HttpScheme)) return path;
if (path == null) return "/";
String[] segments = path.split("/");
if (segments.length < 2) return path;
@@ -604,7 +609,7 @@
int n = bpath.lastIndexOf('/');
if (n > -1) buf.append(bpath.substring(0,n+1));
if (cpath.length() != 0) buf.append(cpath);
- return normalize(buf.toString());
+ return normalize(new HttpScheme(),buf.toString());
}
public IRI resolve(IRI iri) {