You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sa...@apache.org on 2001/11/12 21:24:30 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/util URI.java

sandygao    01/11/12 12:24:30

  Modified:    java/src/org/apache/xerces/util URI.java
  Log:
  Fixing bug [3375]: allow a valid uri string.
  
  Revision  Changes    Path
  1.3       +14 -8     xml-xerces/java/src/org/apache/xerces/util/URI.java
  
  Index: URI.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/util/URI.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- URI.java	2001/08/23 00:35:32	1.2
  +++ URI.java	2001/11/12 20:24:30	1.3
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999,2000 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999,2001 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -88,7 +88,7 @@
   * default port for a specific scheme). Rather, it only knows the
   * grammar and basic set of operations that can be applied to a URI.
   *
  -* @version  $Id: URI.java,v 1.2 2001/08/23 00:35:32 lehors Exp $
  +* @version  $Id: URI.java,v 1.3 2001/11/12 20:24:30 sandygao Exp $
   *
   **********************************************************************/
    public class URI implements Serializable {
  @@ -377,12 +377,18 @@
       int uriSpecLen = uriSpec.length();
       int index = 0;
   
  -    // Check for scheme, which must be before `/'. Also handle names with
  -    // DOS drive letters ('D:'), so 1-character schemes are not allowed.
  -    int colonIdx = uriSpec.indexOf(':');
  -    int slashIdx = uriSpec.indexOf('/');
  -    if ((colonIdx < 2) || (colonIdx > slashIdx && slashIdx != -1)) {
  -      int fragmentIdx = uriSpec.indexOf('#');
  +    // Check for scheme, which must be before '/', '?' or '#'. Also handle
  +    // names with DOS drive letters ('D:'), so 1-character schemes are not
  +    // allowed.
  +    int colonIdx    = uriSpec.indexOf(':');
  +    int slashIdx    = uriSpec.indexOf('/');
  +    int queryIdx    = uriSpec.indexOf('?');
  +    int fragmentIdx = uriSpec.indexOf('#');
  +
  +    if ((colonIdx < 2) ||
  +        (colonIdx > slashIdx && slashIdx != -1) ||
  +        (colonIdx > queryIdx && queryIdx != -1) ||
  +        (colonIdx > fragmentIdx && fragmentIdx != -1)) {
         // A standalone base is a valid URI according to spec
         if (p_base == null && fragmentIdx != 0 ) {
           throw new MalformedURIException("No scheme found in URI.");
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org