From 4e7fd277245c8f5bcb7f459aef1aebee8c828e85 Mon Sep 17 00:00:00 2001 From: Guillaume Turri Date: Tue, 20 Jun 2023 22:52:55 +0200 Subject: [PATCH] Adds support for CDATA sections in server responses This fixes #141 --- Changelog | 2 ++ src/main/java/de/timroes/axmlrpc/XMLUtil.java | 2 +- .../de/timroes/axmlrpc/serializer/TestResponseParser.java | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) 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()