Skip to content

Commit

Permalink
reproduce the second case jhy#1341
Browse files Browse the repository at this point in the history
  • Loading branch information
duanyang25 committed Dec 7, 2021
1 parent 496ccef commit 97a18b9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/test/java/org/jsoup/parser/AttributeParseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,28 @@ public class AttributeParseTest {
doc = Jsoup.parse(html, "", Parser.xmlParser());
assertEquals("<img onerror=\"doMyJob\" />", doc.html());
}

// Test the attribute name like `xlink:href`
// Issue #1341
// https://github.com/jhy/jsoup/issues/1341
@Test public void handleUnboundPrefixofXlink() {
String h = "<!doctype html>\n" +
"<html lang=\"de\">\n" +
" <head>\n" +
"\n" +
" </head>\n" +
" <body>\n" +
"\t<test:h1>UnboundPrefix</test:h1>\n" +
"\t<svg width=\"180\" height=\"180\" xlink:href=\"UnboundPrefix\">\n" +
" \t<rect x=\"20\" y=\"20\" rx=\"20\" ry=\"20\" width=\"100\" height=\"100\" style=\"fill:lightgray; stroke:#1c87c9; stroke-width:4;\"/>\n" +
" \t</svg>\n" +
" </body>\n" +
"</html>\n";

Document doc = Jsoup.parse(h);

Element rv = doc.select("body").get(0).children().get(1);

assertEquals("UnboundPrefix", rv.attributes().get("xlink:href"));
}
}

0 comments on commit 97a18b9

Please sign in to comment.