File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
src/test/java/org/json/junit Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -764,5 +764,29 @@ public void testToJsonXML() {
764764
765765 assertEquals (expectedReverseXml , reverseXml );
766766 }
767+
768+ /**
769+ * test to validate certain conditions of XML unescaping.
770+ */
771+ @ Test
772+ public void testUnescape () {
773+ assertEquals ("{\" xml\" :\" Can cope <;\" }" ,
774+ XML .toJSONObject ("<xml>Can cope <; </xml>" ).toString ());
775+ assertEquals ("Can cope <; " , XML .unescape ("Can cope <; " ));
776+
777+ assertEquals ("{\" xml\" :\" Can cope & ;\" }" ,
778+ XML .toJSONObject ("<xml>Can cope & ; </xml>" ).toString ());
779+ assertEquals ("Can cope & ; " , XML .unescape ("Can cope & ; " ));
780+
781+ assertEquals ("{\" xml\" :\" Can cope &;\" }" ,
782+ XML .toJSONObject ("<xml>Can cope &; </xml>" ).toString ());
783+ assertEquals ("Can cope &; " , XML .unescape ("Can cope &; " ));
784+
785+ // double escaped
786+ assertEquals ("{\" xml\" :\" Can cope <\" }" ,
787+ XML .toJSONObject ("<xml>Can cope &lt; </xml>" ).toString ());
788+ assertEquals ("Can cope < " , XML .unescape ("Can cope &lt; " ));
789+
790+ }
767791
768792}
You can’t perform that action at this time.
0 commit comments