Convert HTML width/height digits only

pull/159/head
M66B 5 years ago
parent 44a8381290
commit 9d234aa9a4

@ -238,21 +238,19 @@ public class HtmlHelper {
int width = 0;
int height = 0;
try {
String awidth = img.attr("width");
if (!TextUtils.isEmpty(awidth) && !"auto".equals(awidth.toLowerCase()))
width = Integer.parseInt(awidth);
} catch (NumberFormatException ex) {
Log.w(ex);
}
try {
String aheight = img.attr("height");
if (!TextUtils.isEmpty(aheight) && !"auto".equals(aheight.toLowerCase()))
height = Integer.parseInt(aheight);
} catch (NumberFormatException ex) {
Log.w(ex);
}
String awidth = img.attr("width");
for (int i = 0; i < awidth.length(); i++)
if (Character.isDigit(awidth.charAt(i)))
width = width * 10 + (byte) awidth.charAt(i) - (byte) '0';
else
break;
String aheight = img.attr("height");
for (int i = 0; i < aheight.length(); i++)
if (Character.isDigit(aheight.charAt(i)))
height = height * 10 + (byte) aheight.charAt(i) - (byte) '0';
else
break;
if (width != 0 || height != 0) {
String src = img.attr("src");

Loading…
Cancel
Save