bug 1027634 - crash in java.net.MalformedURLException: Unknown protocol: textstyle at java.net.URL.<init>(URL.java) r=snorp

This commit is contained in:
Brad Lassey 2014-06-19 10:33:24 -04:00
parent 782d1b99f9
commit 56e1db7e51

View File

@ -2706,20 +2706,24 @@ public class GeckoAppShell
}
@WrapElementForJNI(allowMultithread = true, narrowChars = true)
static URLConnection getConnection(String url) throws MalformedURLException, IOException {
String spec;
if (url.startsWith("android://")) {
spec = url.substring(10);
} else {
spec = url.substring(8);
}
static URLConnection getConnection(String url) {
try {
String spec;
if (url.startsWith("android://")) {
spec = url.substring(10);
} else {
spec = url.substring(8);
}
// if the colon got stripped, put it back
int colon = spec.indexOf(':');
if (colon == -1 || colon > spec.indexOf('/')) {
spec = spec.replaceFirst("/", ":/");
// if the colon got stripped, put it back
int colon = spec.indexOf(':');
if (colon == -1 || colon > spec.indexOf('/')) {
spec = spec.replaceFirst("/", ":/");
}
} catch(Exception ex) {
return null;
}
return new URL(spec).openConnection();
return null;
}
@WrapElementForJNI(allowMultithread = true, narrowChars = true)