diff --git a/Changelog b/Changelog index 4ac5125..67833b2 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +Add support for CDATA section in the server response + 1.13.0 DateTime serializer format is now injectable diff --git a/src/main/java/de/timroes/axmlrpc/XMLUtil.java b/src/main/java/de/timroes/axmlrpc/XMLUtil.java index efefed6..8df9708 100644 --- a/src/main/java/de/timroes/axmlrpc/XMLUtil.java +++ b/src/main/java/de/timroes/axmlrpc/XMLUtil.java @@ -76,7 +76,7 @@ public static String getOnlyTextContent(NodeList list) throws XMLRPCException { continue; } - if(n.getNodeType() != Node.TEXT_NODE) { + if(n.getNodeType() != Node.TEXT_NODE && n.getNodeType() != Node.CDATA_SECTION_NODE) { throw new XMLRPCException("Element must contain only text elements."); } diff --git a/src/test/java/de/timroes/axmlrpc/serializer/TestResponseParser.java b/src/test/java/de/timroes/axmlrpc/serializer/TestResponseParser.java index b5361ed..5926078 100644 --- a/src/test/java/de/timroes/axmlrpc/serializer/TestResponseParser.java +++ b/src/test/java/de/timroes/axmlrpc/serializer/TestResponseParser.java @@ -72,6 +72,13 @@ public void canParseDateTime() throws Exception { assertTrue("Should have thrown because date was empty and we used the default behavior", didThrow); } + @Test + public void canParseResponseWithCDATA() throws Exception { + setMockWithXmlRpcContent("cd]]>"); + + assertEquals("ab<&>cd", makeDummyCall()); + } + private void setMockWithXmlRpcContent(String content){ stubFor(post(urlEqualTo(endPoint)) .willReturn(aResponse()