Lines 88-94
Link Here
|
88 |
* default port for a specific scheme). Rather, it only knows the |
88 |
* default port for a specific scheme). Rather, it only knows the |
89 |
* grammar and basic set of operations that can be applied to a URI. |
89 |
* grammar and basic set of operations that can be applied to a URI. |
90 |
* |
90 |
* |
91 |
* @version $Id: URI.java,v 1.4 2000/12/20 17:31:25 lehors Exp $ |
91 |
* @version $Id: URI.java,v 1.8 2001/07/13 17:54:04 sandygao Exp $ |
92 |
* |
92 |
* |
93 |
**********************************************************************/ |
93 |
**********************************************************************/ |
94 |
public class URI implements Serializable { |
94 |
public class URI implements Serializable { |
Lines 380-386
Link Here
|
380 |
// Check for scheme, which must be before `/'. Also handle names with |
380 |
// Check for scheme, which must be before `/'. Also handle names with |
381 |
// DOS drive letters ('D:'), so 1-character schemes are not allowed. |
381 |
// DOS drive letters ('D:'), so 1-character schemes are not allowed. |
382 |
int colonIdx = uriSpec.indexOf(':'); |
382 |
int colonIdx = uriSpec.indexOf(':'); |
383 |
if ((colonIdx < 2) || (colonIdx > uriSpec.indexOf('/'))) { |
383 |
int slashIdx = uriSpec.indexOf('/'); |
|
|
384 |
if ((colonIdx < 2) || (colonIdx > slashIdx && slashIdx != -1)) { |
384 |
int fragmentIdx = uriSpec.indexOf('#'); |
385 |
int fragmentIdx = uriSpec.indexOf('#'); |
385 |
// A standalone base is a valid URI according to spec |
386 |
// A standalone base is a valid URI according to spec |
386 |
if (p_base == null && fragmentIdx != 0 ) { |
387 |
if (p_base == null && fragmentIdx != 0 ) { |
Lines 503-531
Link Here
|
503 |
|
504 |
|
504 |
// 6e - remove all "<segment>/../" where "<segment>" is a complete |
505 |
// 6e - remove all "<segment>/../" where "<segment>" is a complete |
505 |
// path segment not equal to ".." |
506 |
// path segment not equal to ".." |
506 |
index = -1; |
507 |
index = 1; |
507 |
int segIndex = -1; |
508 |
int segIndex = -1; |
508 |
String tempString = null; |
|
|
509 |
|
509 |
|
510 |
while ((index = path.indexOf("/../")) > 0) { |
510 |
while ((index = path.indexOf("/../", index)) > 0) { |
511 |
tempString = path.substring(0, path.indexOf("/../")); |
511 |
segIndex = path.lastIndexOf('/', index-1); |
512 |
segIndex = tempString.lastIndexOf('/'); |
512 |
if (segIndex != -1 && !path.substring(segIndex+1, index).equals("..")) { |
513 |
if (segIndex != -1) { |
513 |
path = path.substring(0, segIndex).concat(path.substring(index+3)); |
514 |
if (!tempString.substring(segIndex++).equals("..")) { |
514 |
index = segIndex; |
515 |
path = path.substring(0, segIndex).concat(path.substring(index+4)); |
515 |
} else { |
516 |
} |
516 |
index += 4; |
517 |
} |
517 |
} |
518 |
} |
518 |
} |
519 |
|
519 |
|
520 |
// 6f - remove ending "<segment>/.." where "<segment>" is a |
520 |
// 6f - remove ending "<segment>/.." where "<segment>" is a |
521 |
// complete path segment |
521 |
// complete path segment |
522 |
if (path.endsWith("/..")) { |
522 |
if (path.endsWith("/..")) { |
523 |
tempString = path.substring(0, path.length()-3); |
523 |
index = path.length()-3; |
524 |
segIndex = tempString.lastIndexOf('/'); |
524 |
segIndex = path.lastIndexOf('/', index-1); |
525 |
if (segIndex != -1) { |
525 |
if (segIndex != -1 && !path.substring(segIndex+1, index).equals("..")) { |
526 |
path = path.substring(0, segIndex+1); |
526 |
path = path.substring(0, segIndex+1); |
527 |
} |
527 |
} |
528 |
} |
528 |
} |
|
|
529 |
|
529 |
m_path = path; |
530 |
m_path = path; |
530 |
} |
531 |
} |
531 |
} |
532 |
} |