PatchSet 5871 
Date: 2005/01/18 15:18:42
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU Classpath: URI fixes

2005-01-18  Dalibor Topic  <[EMAIL PROTECTED]>

Resynced with GNU Classpath.

2005-01-17  Michael Koch  <[EMAIL PROTECTED]>

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.

Members: 
        ChangeLog:1.3412->1.3413 
        libraries/javalib/java/net/URI.java:1.9->1.10 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3412 kaffe/ChangeLog:1.3413
--- kaffe/ChangeLog:1.3412      Tue Jan 18 15:14:47 2005
+++ kaffe/ChangeLog     Tue Jan 18 15:18:42 2005
@@ -1,6 +1,22 @@
 2005-01-18  Dalibor Topic  <[EMAIL PROTECTED]>
 
        Resynced with GNU Classpath.
+       
+       2005-01-17  Michael Koch  <[EMAIL PROTECTED]>
+
+       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-18  Dalibor Topic  <[EMAIL PROTECTED]>
+
+       Resynced with GNU Classpath.
 
        2005-01-17  Jerry Quinn  <[EMAIL PROTECTED]>
 
Index: kaffe/libraries/javalib/java/net/URI.java
diff -u kaffe/libraries/javalib/java/net/URI.java:1.9 
kaffe/libraries/javalib/java/net/URI.java:1.10
--- kaffe/libraries/javalib/java/net/URI.java:1.9       Sat Oct 16 13:31:00 2004
+++ kaffe/libraries/javalib/java/net/URI.java   Tue Jan 18 15:18:49 2005
@@ -1,5 +1,5 @@
-/* URI.java - An URI class --
-   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+/* URI.java -- An URI class
+   Copyright (C) 2002, 2004, 2005  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -35,6 +35,7 @@
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
+
 package java.net;
 
 import java.io.IOException;
@@ -44,7 +45,6 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-
 /**
  * @author Ito Kazumitsu ([EMAIL PROTECTED])
  * @author Dalibor Topic ([EMAIL PROTECTED])
@@ -64,6 +64,9 @@
   private static final String URI_REGEXP =
     "^(([^:/?#]+):)?((//([^/?#]*))?([^?#]*)(\\?([^#]*))?)?(#(.*))?";
 
+  private static final String AUTHORITY_REGEXP =
+    "^(([^?#]*)@([^?#]*):([^?#]*))?";
+
   /**
    * Valid characters (taken from rfc2396)
    */
@@ -111,6 +114,11 @@
    * Index of fragment component in parsed URI.
    */
   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 rawSchemeSpecificPart;
   private transient String schemeSpecificPart;
@@ -120,7 +128,7 @@
   private transient String userInfo;
   private transient String rawHost;
   private transient String host;
-  private transient int port;
+  private transient int port = -1;
   private transient String rawPath;
   private transient String path;
   private transient String rawQuery;
@@ -168,6 +176,7 @@
   {
     Pattern pattern = Pattern.compile(URI_REGEXP);
     Matcher matcher = pattern.matcher(str);
+    
     if (matcher.matches())
       {
        scheme = getURIGroup(matcher, SCHEME_GROUP);
@@ -180,10 +189,42 @@
     else
       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 may throw an exception.
     schemeSpecificPart = unquote(rawSchemeSpecificPart);
     authority = unquote(rawAuthority);
+    userInfo = unquote(rawUserInfo);
+    host = unquote(rawHost);
     path = unquote(rawPath);
     query = unquote(rawQuery);
     fragment = unquote(rawFragment);

_______________________________________________
kaffe mailing list
[email protected]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to