Source:
<code>private static void processTagsWithAttributes(Document doc) { if (allowedAttributes == null) { allowedAttributes = new ArrayList<String>(); allowedAttributes.add("border"); allowedAttributes.add("frame"); allowedAttributes.add("rules"); allowedAttributes.add("valign"); allowedAttributes.add("src"); } Elements tables = doc.select("table"); for (Element table : tables) { removeUnsupportedAttributes(table, true); Elements colgroup = table.select("colgroup"); for (Element c : colgroup) { c.remove(); } removeElements(table, "thead"); removeElements(table, "tfoot"); removeElements(table, "tbody"); Elements rows = table.select("td"); for (Element row : rows) { String[] attributeValues = removeUnsupportedAttributes(row, false); Element tr = null; Element parent = row.parent(); if (parent.tagName().equals("tr")) { tr = parent; } else { Elements siblings = row.siblingElements(); for (Element e : siblings) { if (e.tagName().equals("tr")) { tr = e; break; } } } if (tr != null) { for (int i = 0; i < attributeValues.length; i++) { if (attributeValues[i] != null) { tr.attr(allowedAttributes.get(i), attributeValues[i].toLowerCase()); } } } } rows = table.select("tr"); for (Element row : rows) { removeUnsupportedAttributes(row, true); } } Elements images = doc.select("img"); <START> for (Element image : images) { <END> String[] attributeValues = {null, null, null, null, null}; Attributes attr = image.attributes(); for (Attribute a : attr) { if (allowedAttributes.contains(a.getKey())) { if (!(a.getKey().equals("border") && a.getValue().equals("0"))) { attributeValues[allowedAttributes.indexOf(a.getKey())] = a.getValue(); } } image.removeAttr(a.getKey()); } for (int i = 0; i < attributeValues.length; i++) { if (attributeValues[i] != null) { image.attr(allowedAttributes.get(i), attributeValues[i]); } } } }</code><technical_language>This section of code replaced new method - removeUnsupportedAttributes (down 241)</technical_language>

Target:
private static void processTagsWithAttributes(Document doc) { if (allowedAttributes == null) { allowedAttributes = new ArrayList<String>(); allowedAttributes.add("border"); allowedAttributes.add("frame"); allowedAttributes.add("rules"); allowedAttributes.add("valign"); allowedAttributes.add("src"); } Elements tables = doc.select("table"); for (Element table : tables) { removeUnsupportedAttributes(table, true); Elements colgroup = table.select("colgroup"); for (Element c : colgroup) { c.remove(); } removeElements(table, "thead"); removeElements(table, "tfoot"); removeElements(table, "tbody"); Elements rows = table.select("td"); for (Element row : rows) { String[] attributeValues = removeUnsupportedAttributes(row, false); Element tr = null; Element parent = row.parent(); if (parent.tagName().equals("tr")) { tr = parent; } else { Elements siblings = row.siblingElements(); for (Element e : siblings) { if (e.tagName().equals("tr")) { tr = e; break; } } } if (tr != null) { for (int i = 0; i < attributeValues.length; i++) { if (attributeValues[i] != null) { tr.attr(allowedAttributes.get(i), attributeValues[i].toLowerCase()); } } } } rows = table.select("tr"); for (Element row : rows) { removeUnsupportedAttributes(row, true); } } Elements images = doc.select("img"); for (Element image : images) { removeUnsupportedAttributes(image, true); } }