Skip to content

Commit

Permalink
Apply attribute normalization to void tags
Browse files Browse the repository at this point in the history
  • Loading branch information
kalaider authored and jhy committed Feb 15, 2020
1 parent 62c0595 commit 1d9f465
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/org/jsoup/parser/HtmlTreeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void insert(Element el) {

Element insertEmpty(Token.StartTag startTag) {
Tag tag = Tag.valueOf(startTag.name(), settings);
Element el = new Element(tag, null, startTag.attributes);
Element el = new Element(tag, null, settings.normalizeAttributes(startTag.attributes));
insertNode(el);
if (startTag.isSelfClosing()) {
if (tag.isKnownTag()) {
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/org/jsoup/parser/HtmlParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,12 @@ public void testInvalidTableContents() throws IOException {
assertEquals("<tag>One</tag>", TextUtil.stripNewlines(div.nextElementSibling().outerHtml()));
}

@Test public void testHtmlLowerCaseOfVoidTags() {
String html = "<!doctype HTML><IMG ALT=One></DIV>";
Document doc = Jsoup.parse(html);
assertEquals("<!doctype html> <html> <head></head> <body> <img alt=\"One\"> </body> </html>", StringUtil.normaliseWhitespace(doc.outerHtml()));
}

@Test public void canPreserveTagCase() {
Parser parser = Parser.htmlParser();
parser.settings(new ParseSettings(true, false));
Expand Down

0 comments on commit 1d9f465

Please sign in to comment.