title: Spring REST controller unable to handle XML payload containing escaped HTML
body: <p>I am writing a Spring controller that will be acting as an event subscriber for a 3rd party platform that we do not have any control over. When content is created or updated in that platform, it will send a <code>POST</code> request to a callback URL we specify. That request will contain information about what has changed, including the body of that content. For this endpoint, we only care about a small subset of the fields, but for some reason when the controller is receiving the body of the request, the escaped HTML characters from the body are breaking the whole document, which in turn breaks the XML parser.</p>
  <p>The simplified controller class I have created is as follows:</p>
  <pre class="lang-java prettyprint-override"><code>@RestController
  public class Controller {
  
    @PostMapping(path = &quot;/listenerOne&quot;)
    public ResponseEntity&lt;String&gt; listenerOne(
        @RequestParam(name = &quot;event.type&quot;) final String eventType,
        @RequestParam(name = &quot;message&quot;, required = false) final String xmlPayload) {
      return ResponseEntity.ok().body(xmlPayload);
    }
  
    @PostMapping(path = &quot;/listenerTwo&quot;, consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
    public ResponseEntity&lt;String&gt; listenerTwo(@RequestBody final MultiValueMap&lt;String, String&gt; messageEvent) {
      return ResponseEntity.ok().body(messageEvent.toString());
    }
  
  }
  </code></pre>
  <p><code>message-event.xml</code> is a sample of the request parameter captured from a log message.</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;message type=&quot;message&quot; href=&quot;/messages/id/1313133&quot;&gt;
      &lt;body type=&quot;string&quot;&gt;&amp;lt;P&amp;gt;Test body&amp;lt;/P&amp;gt;&lt;/body&gt;
      &lt;subject type=&quot;string&quot;&gt;Test message&lt;/subject&gt;
      &lt;id type=&quot;int&quot;&gt;1313133&lt;/id&gt;
  &lt;/message&gt;
  </code></pre>
  <pre class="lang-bash prettyprint-override"><code>curl -XPOST localhost:8080/listenerOne -d &quot;event.type=MessageUpdate&amp;message=$(cat message-event.xml)&quot;
  &lt;message type=&quot;message&quot; href=&quot;/messages/id/1313133&quot;&gt;
      &lt;body type=&quot;string&quot;&gt;%
  </code></pre>
  <pre class="lang-bash prettyprint-override"><code>curl -XPOST localhost:8080/listenerTwo -d &quot;event.type=MessageUpdate&amp;message=$(cat message-event.xml)&quot;
  {event.type=[MessageUpdate], message=[&lt;message type=&quot;message&quot; href=&quot;/messages/id/1313133&quot;&gt;
      &lt;body type=&quot;string&quot;&gt;], lt;P=[], gt;Test body=[], lt;/P=[], gt;&lt;/body&gt;
      &lt;subject type=[&quot;string&quot;&gt;Test message&lt;/subject&gt;
      &lt;id type=&quot;int&quot;&gt;1313133&lt;/id&gt;
  &lt;/message&gt;]}%
  </code></pre>
  <p>As you can see, everything after <code>&lt;body type=&quot;string&quot;&gt;</code> is being removed. Any ideas on why this is splitting the request body/parameters?</p>