-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
util: do not crash on
jar:
relative URIs of less than 4 characters,…
… avoid string creation
- Loading branch information
Showing
2 changed files
with
21 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,10 @@ | |
* Protocol Handler for the 'jar' protocol. This appears to have the format: | ||
* jar:<URL for jar file>!<path in jar file> | ||
* | ||
* @author <a href="mailto:[email protected]">Thomas DeWeese</a> | ||
* @author For later modifications, see Git history. | ||
* <p> | ||
* Original author: <a href="mailto:[email protected]">Thomas DeWeese</a> | ||
* For later modifications, see Git history. | ||
* </p> | ||
* @version $Id$ | ||
*/ | ||
public class ParsedURLJarProtocolHandler extends ParsedURLDefaultProtocolHandler { | ||
|
@@ -42,10 +44,8 @@ public ParsedURLJarProtocolHandler() { | |
// is an absolute URL. | ||
@Override | ||
public ParsedURLData parseURL(ParsedURL baseURL, String urlStr) { | ||
String start = urlStr.substring(0, JAR.length() + 1).toLowerCase(); | ||
|
||
// urlStr is absolute... | ||
if (start.equals(JAR + ":")) | ||
// Check whether urlStr is absolute... | ||
if (startsWithJarColon(urlStr)) | ||
return parseURL(urlStr); | ||
|
||
// It's relative so base it off baseURL. | ||
|
@@ -58,4 +58,11 @@ public ParsedURLData parseURL(ParsedURL baseURL, String urlStr) { | |
} | ||
} | ||
|
||
private boolean startsWithJarColon(String url) { | ||
char c; | ||
return url.length() > 3 && ((c = url.charAt(0)) == 'j' || c == 'J') | ||
&& ((c = url.charAt(1)) == 'a' || c == 'A') | ||
&& ((c = url.charAt(2)) == 'r' || c == 'R') && url.charAt(3) == ':'; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters