Skip to content

Commit

Permalink
Adds support for CDATA sections in server responses
Browse files Browse the repository at this point in the history
This fixes #141
  • Loading branch information
gturri committed Jun 20, 2023
1 parent a9e9f18 commit 4e7fd27
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Add support for CDATA section in the server response

1.13.0
DateTime serializer format is now injectable

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/timroes/axmlrpc/XMLUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("<value><string><![CDATA[ab<&>cd]]></string></value>");

assertEquals("ab<&>cd", makeDummyCall());
}

private void setMockWithXmlRpcContent(String content){
stubFor(post(urlEqualTo(endPoint))
.willReturn(aResponse()
Expand Down

0 comments on commit 4e7fd27

Please sign in to comment.