re PR java/19444 (GCJ implementation of java.net.URI misses host support)
2005-01-15 Michael Koch <konqueror@gmx.de> PR libgcj/19444 * java/net/URI.java (AUTHORITY_REGEXP): New regexp constant. (AUTHORITY_USERINFO_GROUP): New constant. (AUTHORITY_HOST_GROUP): Likewise. (AUTHORITY_PORT_GROUP): Likewise. (port): Changed default value to -1. (parseURI): Parse authority part and initialize host, port and userInfo. From-SVN: r93711
This commit is contained in:
parent
01c4f82a92
commit
4b8a70aa26
@ -1,3 +1,15 @@
|
|||||||
|
2005-01-15 Michael Koch <konqueror@gmx.de>
|
||||||
|
|
||||||
|
PR libgcj/19444
|
||||||
|
* java/net/URI.java
|
||||||
|
(AUTHORITY_REGEXP): New regexp constant.
|
||||||
|
(AUTHORITY_USERINFO_GROUP): New constant.
|
||||||
|
(AUTHORITY_HOST_GROUP): Likewise.
|
||||||
|
(AUTHORITY_PORT_GROUP): Likewise.
|
||||||
|
(port): Changed default value to -1.
|
||||||
|
(parseURI): Parse authority part and initialize host,
|
||||||
|
port and userInfo.
|
||||||
|
|
||||||
2005-01-14 Robin Green <greenrd@greenrd.org>
|
2005-01-14 Robin Green <greenrd@greenrd.org>
|
||||||
|
|
||||||
* java/io/File.java (toURI): Generate a URI which we understand.
|
* java/io/File.java (toURI): Generate a URI which we understand.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* URI.java - An URI class --
|
/* URI.java -- An URI class
|
||||||
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GNU Classpath.
|
This file is part of GNU Classpath.
|
||||||
|
|
||||||
@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
|
|||||||
obligated to do so. If you do not wish to do so, delete this
|
obligated to do so. If you do not wish to do so, delete this
|
||||||
exception statement from your version. */
|
exception statement from your version. */
|
||||||
|
|
||||||
|
|
||||||
package java.net;
|
package java.net;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -44,7 +45,6 @@ import java.io.Serializable;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ito Kazumitsu (ito.kazumitsu@hitachi-cable.co.jp)
|
* @author Ito Kazumitsu (ito.kazumitsu@hitachi-cable.co.jp)
|
||||||
* @author Dalibor Topic (robilad@kaffe.org)
|
* @author Dalibor Topic (robilad@kaffe.org)
|
||||||
@ -64,6 +64,9 @@ public final class URI implements Comparable, Serializable
|
|||||||
private static final String URI_REGEXP =
|
private static final String URI_REGEXP =
|
||||||
"^(([^:/?#]+):)?((//([^/?#]*))?([^?#]*)(\\?([^#]*))?)?(#(.*))?";
|
"^(([^:/?#]+):)?((//([^/?#]*))?([^?#]*)(\\?([^#]*))?)?(#(.*))?";
|
||||||
|
|
||||||
|
private static final String AUTHORITY_REGEXP =
|
||||||
|
"^(([^?#]*)@([^?#]*):([^?#]*))?";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Valid characters (taken from rfc2396)
|
* Valid characters (taken from rfc2396)
|
||||||
*/
|
*/
|
||||||
@ -111,6 +114,11 @@ public final class URI implements Comparable, Serializable
|
|||||||
* Index of fragment component in parsed URI.
|
* Index of fragment component in parsed URI.
|
||||||
*/
|
*/
|
||||||
private static final int FRAGMENT_GROUP = 10;
|
private static final int FRAGMENT_GROUP = 10;
|
||||||
|
|
||||||
|
private static final int AUTHORITY_USERINFO_GROUP = 2;
|
||||||
|
private static final int AUTHORITY_HOST_GROUP = 3;
|
||||||
|
private static final int AUTHORITY_PORT_GROUP = 4;
|
||||||
|
|
||||||
private transient String scheme;
|
private transient String scheme;
|
||||||
private transient String rawSchemeSpecificPart;
|
private transient String rawSchemeSpecificPart;
|
||||||
private transient String schemeSpecificPart;
|
private transient String schemeSpecificPart;
|
||||||
@ -120,7 +128,7 @@ public final class URI implements Comparable, Serializable
|
|||||||
private transient String userInfo;
|
private transient String userInfo;
|
||||||
private transient String rawHost;
|
private transient String rawHost;
|
||||||
private transient String host;
|
private transient String host;
|
||||||
private transient int port;
|
private transient int port = -1;
|
||||||
private transient String rawPath;
|
private transient String rawPath;
|
||||||
private transient String path;
|
private transient String path;
|
||||||
private transient String rawQuery;
|
private transient String rawQuery;
|
||||||
@ -168,6 +176,7 @@ public final class URI implements Comparable, Serializable
|
|||||||
{
|
{
|
||||||
Pattern pattern = Pattern.compile(URI_REGEXP);
|
Pattern pattern = Pattern.compile(URI_REGEXP);
|
||||||
Matcher matcher = pattern.matcher(str);
|
Matcher matcher = pattern.matcher(str);
|
||||||
|
|
||||||
if (matcher.matches())
|
if (matcher.matches())
|
||||||
{
|
{
|
||||||
scheme = getURIGroup(matcher, SCHEME_GROUP);
|
scheme = getURIGroup(matcher, SCHEME_GROUP);
|
||||||
@ -180,10 +189,42 @@ public final class URI implements Comparable, Serializable
|
|||||||
else
|
else
|
||||||
throw new URISyntaxException(str, "doesn't match URI regular expression");
|
throw new URISyntaxException(str, "doesn't match URI regular expression");
|
||||||
|
|
||||||
|
if (rawAuthority != null)
|
||||||
|
{
|
||||||
|
pattern = Pattern.compile(AUTHORITY_REGEXP);
|
||||||
|
matcher = pattern.matcher(rawAuthority);
|
||||||
|
|
||||||
|
if (matcher.matches())
|
||||||
|
{
|
||||||
|
rawUserInfo = getURIGroup(matcher, AUTHORITY_USERINFO_GROUP);
|
||||||
|
rawHost = getURIGroup(matcher, AUTHORITY_HOST_GROUP);
|
||||||
|
|
||||||
|
String portStr = getURIGroup(matcher, AUTHORITY_PORT_GROUP);
|
||||||
|
|
||||||
|
if (portStr != null)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
port = Integer.parseInt(portStr);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException e)
|
||||||
|
{
|
||||||
|
URISyntaxException use =
|
||||||
|
new URISyntaxException
|
||||||
|
(str, "doesn't match URI regular expression");
|
||||||
|
use.initCause(e);
|
||||||
|
throw use;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw new URISyntaxException(str, "doesn't match URI regular expression");
|
||||||
|
}
|
||||||
|
|
||||||
// We must eagerly unquote the parts, because this is the only time
|
// We must eagerly unquote the parts, because this is the only time
|
||||||
// we may throw an exception.
|
// we may throw an exception.
|
||||||
schemeSpecificPart = unquote(rawSchemeSpecificPart);
|
schemeSpecificPart = unquote(rawSchemeSpecificPart);
|
||||||
authority = unquote(rawAuthority);
|
authority = unquote(rawAuthority);
|
||||||
|
userInfo = unquote(rawUserInfo);
|
||||||
|
host = unquote(rawHost);
|
||||||
path = unquote(rawPath);
|
path = unquote(rawPath);
|
||||||
query = unquote(rawQuery);
|
query = unquote(rawQuery);
|
||||||
fragment = unquote(rawFragment);
|
fragment = unquote(rawFragment);
|
||||||
|
Loading…
Reference in New Issue
Block a user