0

I have an issue reading an XML string parameter from the request body.

Giving the following HTML:

<!DOCTYPE html>
<html>

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

<body>

<form action="http://localhost:8080/action" method="post">
  <input type="hidden" name="TEST" value="<test>mytest</test>"/>    
  <input type="submit" value="Submit">
</form>

</body>
</html>

And the following @PostMapping action:

@PostMapping
public void action(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String context = request.getParameter("TEST");
    System.out.println(context);
}

In the ouput console I have mytest instead of <test>mytest</test>

The String is losing its Html entities.

What's missing?

Alessandro C
  • 3,310
  • 9
  • 46
  • 82

1 Answers1

0

I had a Jsoup dependency that was the cause of the issue. Jsoup removes every tag that's not defined in a proper Whitelist.

Alessandro C
  • 3,310
  • 9
  • 46
  • 82