* FYI: SocketPermission tweak
@ 2006-09-05 7:44 Gary Benson
0 siblings, 0 replies; only message in thread
From: Gary Benson @ 2006-09-05 7:44 UTC (permalink / raw)
To: java-patches
[-- Attachment #1: Type: text/plain, Size: 166 bytes --]
Hi all,
This commit makes java.net.SocketPermission()'s constructor use
"localhost" when called with an empty hostport argument in line
with the spec.
Cheers,
Gary
[-- Attachment #2: socketpermission-merge.patch --]
[-- Type: text/plain, Size: 2662 bytes --]
Index: classpath/ChangeLog.gcj
===================================================================
--- classpath/ChangeLog.gcj (revision 116678)
+++ classpath/ChangeLog.gcj (working copy)
@@ -1,3 +1,11 @@
+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).
+
2006-08-31 Keith Seitz <keiths@redhat.com>
* include/jvmti.h: Update from Classpath to get latest fixes and
Index: classpath/java/net/SocketPermission.java
===================================================================
--- classpath/java/net/SocketPermission.java (revision 116678)
+++ classpath/java/net/SocketPermission.java (working copy)
@@ -164,21 +164,26 @@
*/
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,12 +226,8 @@
{
// Split into host and ports
String ports;
- if (hostport.length() == 0)
+ if (hostport.charAt(0) == '[')
{
- host = ports = "";
- }
- else if (hostport.charAt(0) == '[')
- {
// host is a bracketed IPv6 address
int end = hostport.indexOf("]");
if (end == -1)
@@ -255,8 +256,6 @@
ports = hostport.substring(sep + 1);
}
}
- if (ports.indexOf(":") != -1)
- throw new IllegalArgumentException("Unexpected ':'");
// Parse and validate the ports
if (ports.length() == 0)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-09-05 7:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-05 7:44 FYI: SocketPermission tweak Gary Benson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).