Skip to content

Commit

Permalink
more fixes for special windows paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Orbiter committed Jul 10, 2015
1 parent e5b6424 commit 0e87a99
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions source/net/yacy/cora/document/id/MultiProtocolURL.java
Expand Up @@ -277,12 +277,12 @@ public MultiProtocolURL(String url) throws MalformedURLException {
// no host given
this.path = h.substring(2); // "/path" or "/c:/path"
} else if (h.startsWith("//")) { // "//host/path" or "//host/c:/path"
if (h.charAt(3) == ':' && h.charAt(4) != '/' && h.charAt(4) != '\\') {
if (h.length() > 4 && h.charAt(3) == ':' && h.charAt(4) != '/' && h.charAt(4) != '\\') {
// wrong windows path, after the doublepoint there should be a backslash
h = h.substring(0, 4) + '\\' + h.substring(4);
}
int q = h.indexOf('/', 2);
if (q < 0) {
if (q < 0 || h.length() > 3 && h.charAt(3) == ':') {
this.path = h.substring(2); // "path" or "c:/path"
} else {
this.host = h.substring(2, q ); // TODO: handle "c:" ?
Expand Down Expand Up @@ -2314,13 +2314,13 @@ public static String[] urlComps(String normalizedURL) {
if (p > 0) normalizedURL = normalizedURL.substring(p + 2);
return splitpattern.split(normalizedURL.toLowerCase()); // word components of the url
}
/*
public static void main(final String[] args) {
for (final String s: args) System.out.println(toTokens(s));
}
*/

public static void main(final String[] args) {
final String[][] test = new String[][]{
new String[]{null, "file://y:/"},
new String[]{null, "file://y:/yacy"},
new String[]{null, "file://y:/yacy/"},
new String[]{null, "file://y:"},
new String[]{null, "file://Z:admin\\home"}, // thats wrong but may appear
new String[]{null, "file://Z:\\admin\\home"},
new String[]{null, "https://www.example.com/shoe/?p=2&ps=75#t={%22san_NaviPaging%22:2}"}, // ugly strange pagination link
Expand Down Expand Up @@ -2395,6 +2395,10 @@ public static void main(final String[] args) {
System.out.println((jURL == null) ? "jURL rejected input" : "jURL=" + jURL.toString());
System.out.println((aURL == null) ? "aURL rejected input" : "aURL=" + aURL.toNormalform(false) + "; host=" + aURL.getHost() + "; path=" + aURL.getPath() + "; file=" + aURL.getFile());
}

if (aURL != null && jURL != null && jURL.toString().equals(aURL.toNormalform(false))) {
System.out.println("jURL == aURL=" + aURL.toNormalform(false) + "; host=" + aURL.getHost() + "; path=" + aURL.getPath() + "; file=" + aURL.getFile());
}

// check stability: the normalform of the normalform must be equal to the normalform
if (aURL != null) try {
Expand Down

0 comments on commit 0e87a99

Please sign in to comment.