Sanitize style value

This commit is contained in:
M66B 2019-09-24 16:51:51 +02:00
parent 04db86ba9a
commit 36e2f39dbc
1 changed files with 8 additions and 4 deletions

View File

@ -161,7 +161,11 @@ public class HtmlHelper {
if (kv.length == 2)
switch (kv[0].trim().toLowerCase(Locale.ROOT)) {
case "color":
String c = kv[1].trim().toLowerCase(Locale.ROOT);
String c = kv[1]
.toLowerCase(Locale.ROOT)
.replace(" ", "")
.replace("inherit", "")
.replace("!important", "");
Integer color = null;
try {
@ -174,9 +178,9 @@ public class HtmlHelper {
String[] rgb = c.substring(s + 1, e).split(",");
if (rgb.length == 3)
color = Color.rgb(
Integer.parseInt(rgb[0].trim()),
Integer.parseInt(rgb[1].trim()),
Integer.parseInt(rgb[2].trim())
Integer.parseInt(rgb[0]),
Integer.parseInt(rgb[1]),
Integer.parseInt(rgb[2])
);
}
} else