Refactoring

pull/206/head
M66B 3 years ago
parent 3db56f49ea
commit e43744eb88

@ -123,28 +123,30 @@ public class Bimi {
if (TextUtils.isEmpty(l)) if (TextUtils.isEmpty(l))
continue; continue;
Uri ul = Uri.parse(l); try {
if (!"https".equals(ul.getScheme())) { Uri ul = Uri.parse(l);
Log.e("BIMI insecure img=" + l); if ("https".equals(ul.getScheme()))
continue; throw new MalformedURLException(l);
}
URL url = new URL(l); URL url = new URL(l);
Log.i("BIMI favicon " + url); Log.i("BIMI favicon " + url);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("GET"); connection.setRequestMethod("GET");
connection.setReadTimeout(READ_TIMEOUT); connection.setReadTimeout(READ_TIMEOUT);
connection.setConnectTimeout(CONNECT_TIMEOUT); connection.setConnectTimeout(CONNECT_TIMEOUT);
connection.setInstanceFollowRedirects(true); connection.setInstanceFollowRedirects(true);
connection.setRequestProperty("User-Agent", WebViewEx.getUserAgent(context)); connection.setRequestProperty("User-Agent", WebViewEx.getUserAgent(context));
connection.connect(); connection.connect();
try { try {
bitmap = ImageHelper.renderSvg(connection.getInputStream(), bitmap = ImageHelper.renderSvg(connection.getInputStream(),
Color.WHITE, scaleToPixels); Color.WHITE, scaleToPixels);
} finally { } finally {
connection.disconnect(); connection.disconnect();
}
} catch (MalformedURLException ex) {
Log.i(ex);
} }
break; break;
@ -159,13 +161,11 @@ public class Bimi {
if (TextUtils.isEmpty(a)) if (TextUtils.isEmpty(a))
continue; continue;
Uri ua = Uri.parse(a);
if (!"https".equals(ua.getScheme())) {
Log.e("BIMI insecure pem=" + a);
continue;
}
try { try {
Uri ua = Uri.parse(a);
if (!"https".equals(ua.getScheme()))
throw new MalformedURLException(a);
URL url = new URL(a); URL url = new URL(a);
Log.i("BIMI PEM " + url); Log.i("BIMI PEM " + url);

Loading…
Cancel
Save