Jira REST API(rest/3/search/jql): description rendered as markup in browser, but HTML in test how to resolve?

I’m retrieving issues and their fields, including description. According to the Jira API documentation, the description field uses the ADF (Atlassian Document Format), which I’m handling correctly in my code.

Here’s the situation:

  • While testing the response in a test case in java, the description field renders in the expected HTML format after conversion from ADF.

  • However, when I display the same content in a browser, it appears in raw markup (not as rendered HTML).

  • How to resolve it?

Hi @AyashaSikilkar

Yout HTML is showed as a string, not render as HTML.

If you use this kind of expression: {{ htmlString }} (angular/vue), you will see it as text.

You need to sanitized it to avoid XSS

In react, you can duse DomPurify:

import DOMPurify from ‘dompurify’;
const safe = DOMPurify.sanitize(htmlString);
return <div dangerouslySetInnerHTML={{ __html: safe }} />;

Hi @FlixAndre is there any solution in java?

There is Thymeleaf, and other solution, but I don’t use that much Java, and it depends of your needs.

ok thank you

Your welcome,

Hope you will find how to display your HTML in java and sanitize it :slight_smile: