Created
January 22, 2013 19:49
-
-
Save anonymous/4597820 to your computer and use it in GitHub Desktop.
Hippo HtmlRepairer v1.02.06 Div only allows for class attribute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
} else if (startElement.localName.equals(ELEM_DIV)) { | |
String classAttr = startElement.attrs.getValue(ATTR_CLASS); | |
Set<String> allowedDivClasses = template.getAllowedDivClasses(); | |
if (classAttr != null && allowedDivClasses.contains(classAttr)) { | |
AttributesImpl attrs = new AttributesImpl(); | |
attrs.addAttribute(EMPTY_STRING, ATTR_CLASS, ATTR_CLASS, CDATA, classAttr); | |
startElement(ELEM_DIV, attrs); | |
endElements.push(new EndElementInfo(ELEM_DIV)); | |
} else { | |
// unallowed class, drop div element | |
endElements.push(new EndElementInfo()); | |
} | |
} else if (startElement.localName.equals(ELEM_P)) { | |
String classAttr = startElement.attrs.getValue(ATTR_CLASS); | |
Set<String> allowedParaClasses = template.getAllowedParaClasses(); | |
if (classAttr != null && allowedParaClasses.contains(classAttr)) { | |
startElement(ELEM_P, getAllowedAttributes(startElement)); | |
endElements.push(new EndElementInfo(ELEM_P)); | |
} else { | |
AttributesImpl attrs = getAllowedAttributes(startElement); | |
int classPos = attrs.getIndex(ATTR_CLASS); | |
if (classPos != -1) { | |
attrs.removeAttribute(classPos); | |
} | |
startElement(ELEM_P, attrs); | |
endElements.push(new EndElementInfo(ELEM_P)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As we see, div only keep the class attribute vs p which allows the ones configured