@@ -14,7 +14,7 @@ public class EntitiesTest {
14
14
String escapedAscii = Entities .escape (text , new OutputSettings ().charset ("ascii" ).escapeMode (base ));
15
15
String escapedAsciiFull = Entities .escape (text , new OutputSettings ().charset ("ascii" ).escapeMode (extended ));
16
16
String escapedAsciiXhtml = Entities .escape (text , new OutputSettings ().charset ("ascii" ).escapeMode (xhtml ));
17
- String escapedUtfFull = Entities .escape (text , new OutputSettings ().charset ("UTF-8" ).escapeMode (base ));
17
+ String escapedUtfFull = Entities .escape (text , new OutputSettings ().charset ("UTF-8" ).escapeMode (extended ));
18
18
String escapedUtfMin = Entities .escape (text , new OutputSettings ().charset ("UTF-8" ).escapeMode (xhtml ));
19
19
20
20
assertEquals ("Hello &<> Å å π 新 there ¾ © »" , escapedAscii );
@@ -86,4 +86,19 @@ public class EntitiesTest {
86
86
String string = "http://www.foo.com?a=1&num_rooms=1&children=0&int=VA&b=2" ;
87
87
assertEquals (string , Entities .unescape (string ));
88
88
}
89
+
90
+ @ Test public void escapesGtInXmlAttributesButNotInHtml () {
91
+ // https://github.com/jhy/jsoup/issues/528 - < is OK in HTML attribute values, but not in XML
92
+
93
+
94
+ String docHtml = "<a title='<p>One</p>'>One</a>" ;
95
+ Document doc = Jsoup .parse (docHtml );
96
+ Element element = doc .select ("a" ).first ();
97
+
98
+ doc .outputSettings ().escapeMode (base );
99
+ assertEquals ("<a title=\" <p>One</p>\" >One</a>" , element .outerHtml ());
100
+
101
+ doc .outputSettings ().escapeMode (xhtml );
102
+ assertEquals ("<a title=\" <p>One</p>\" >One</a>" , element .outerHtml ());
103
+ }
89
104
}
0 commit comments