Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply attribute normalization to void tags #1323

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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