summaryrefslogtreecommitdiff
path: root/libjava/classpath/java/net
diff options
context:
space:
mode:
authorgary <gary@138bc75d-0d04-0410-961f-82ee72b054a4>2006-09-05 07:49:08 +0000
committergary <gary@138bc75d-0d04-0410-961f-82ee72b054a4>2006-09-05 07:49:08 +0000
commit59c36c3e2b60bfcc2965602efc73e548dc03516e (patch)
treea87f5756d20164c76b4052a9064d6b24917758c2 /libjava/classpath/java/net
parentf98c653afdee9bb9d23bf700a822781c72cc1388 (diff)
downloadgcc-59c36c3e2b60bfcc2965602efc73e548dc03516e.tar.gz
2006-09-05 Gary Benson <gbenson@redhat.com>
* java/net/SocketPermission.java (maybeBracketIPv6Address): Renamed to processHostport. (processHostport): Also translate "" to "localhost". (setHostPort): Remove special cases for empty hostport and for extra colons in hostport (processHostport handles these now). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116694 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/java/net')
-rw-r--r--libjava/classpath/java/net/SocketPermission.java27
1 files changed, 13 insertions, 14 deletions
diff --git a/libjava/classpath/java/net/SocketPermission.java b/libjava/classpath/java/net/SocketPermission.java
index a722fcad4e5..97e93dcbb35 100644
--- a/libjava/classpath/java/net/SocketPermission.java
+++ b/libjava/classpath/java/net/SocketPermission.java
@@ -164,21 +164,26 @@ public final class SocketPermission extends Permission implements Serializable
*/
public SocketPermission(String hostport, String actions)
{
- super(maybeBracketIPv6Address(hostport));
+ super(processHostport(hostport));
setHostPort(getName());
setActions(actions);
}
/**
- * IPv6 addresses in the hostport must either be enclosed by
- * "[" and "]" or be specified in the full uncompressed form.
- * In the latter case proprietary JVMs will quote the address
- * with "[" and "]", so we do to.
+ * There are two cases in which hostport needs rewriting before
+ * being passed to the superclass constructor. If hostport is an
+ * empty string then it is substituted with "localhost". And if
+ * the host part of hostport is a literal IPv6 address in the full
+ * uncompressed form not enclosed with "[" and "]" then we enclose
+ * it with them.
*/
- private static String maybeBracketIPv6Address(String hostport)
+ private static String processHostport(String hostport)
{
- if (hostport.length() == 0 || hostport.charAt(0) == '[')
+ if (hostport.length() == 0)
+ return "localhost";
+
+ if (hostport.charAt(0) == '[')
return hostport;
int colons = 0, last_colon = 0;
@@ -221,11 +226,7 @@ public final class SocketPermission extends Permission implements Serializable
{
// Split into host and ports
String ports;
- if (hostport.length() == 0)
- {
- host = ports = "";
- }
- else if (hostport.charAt(0) == '[')
+ if (hostport.charAt(0) == '[')
{
// host is a bracketed IPv6 address
int end = hostport.indexOf("]");
@@ -255,8 +256,6 @@ public final class SocketPermission extends Permission implements Serializable
ports = hostport.substring(sep + 1);
}
}
- if (ports.indexOf(":") != -1)
- throw new IllegalArgumentException("Unexpected ':'");
// Parse and validate the ports
if (ports.length() == 0)