Index: URI.java =================================================================== RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/utils/Attic/URI.java,v --- URI.java 1.8 +++ URI.java @@ -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.4 2000/12/20 17:31:25 lehors Exp $ +* @version $Id: URI.java,v 1.8 2001/07/13 17:54:04 sandygao Exp $ * **********************************************************************/ public class URI implements Serializable { @@ -380,7 +380,8 @@ // 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(':'); - if ((colonIdx < 2) || (colonIdx > uriSpec.indexOf('/'))) { + int slashIdx = uriSpec.indexOf('/'); + if ((colonIdx < 2) || (colonIdx > slashIdx && slashIdx != -1)) { int fragmentIdx = uriSpec.indexOf('#'); // A standalone base is a valid URI according to spec if (p_base == null && fragmentIdx != 0 ) { @@ -503,29 +504,29 @@ // 6e - remove all "/../" where "" is a complete // path segment not equal to ".." - index = -1; + index = 1; int segIndex = -1; - String tempString = null; - while ((index = path.indexOf("/../")) > 0) { - tempString = path.substring(0, path.indexOf("/../")); - segIndex = tempString.lastIndexOf('/'); - if (segIndex != -1) { - if (!tempString.substring(segIndex++).equals("..")) { - path = path.substring(0, segIndex).concat(path.substring(index+4)); - } + while ((index = path.indexOf("/../", index)) > 0) { + segIndex = path.lastIndexOf('/', index-1); + if (segIndex != -1 && !path.substring(segIndex+1, index).equals("..")) { + path = path.substring(0, segIndex).concat(path.substring(index+3)); + index = segIndex; + } else { + index += 4; } } // 6f - remove ending "/.." where "" is a // complete path segment if (path.endsWith("/..")) { - tempString = path.substring(0, path.length()-3); - segIndex = tempString.lastIndexOf('/'); - if (segIndex != -1) { + index = path.length()-3; + segIndex = path.lastIndexOf('/', index-1); + if (segIndex != -1 && !path.substring(segIndex+1, index).equals("..")) { path = path.substring(0, segIndex+1); } } + m_path = path; } }