0
    task.addText(comment);

This comment has HTML tags. So when we send this comment as mail, we see encoded HTML like this in mail:

<h3>asdasas as<b>asdasdas</b>dasdas<u>dasdasdasd<strike>asdasdasdsadasdasdas<span id="selectionBoundary_1493731518682_030677381665187298" class="rangySelectionBoundary"></span></strike></u></h3>

I want to see not tags, i want to see what tag does for UI.

This is from db of email for email body part:

 b&gt;asdasdas&lt;/b&gt;dasdas&lt;u&gt;dasdasdasd&lt;strike&gt;asdasdasdsadasdasdas&lt;span id=&quot;selectionBoundary_1493731518682_030677381665187298&quot; class=&quot;rangySelectionBoundary&quot;&gt;&lt;/span&gt;&lt;/strike&gt;&lt;/u&gt;&lt;/h3&gt;</td>\n

this is html part of email:

<p th:if="${!commentsInTask.empty}">Tüm yorumlar: </p>
<table

    <tbody>
    <tr th:each="allComments : ${comments}">
    <tr th:each="comment : ${comments}">
    </tr>
    </tr>
    </tbody>
</table>
</body>
</html>

NOrmally there was no decoding but i saw from here

Java: How to unescape HTML character entities in Java?

and did this

comment=StringEscapeUtils.unescapeHtml(comment);

but did not work.

this is from comment db:

<h3>asdasas as<b>asdasdas</b>dasdas<u>dasdasdasd<strike>asdasdasdsadasdasdas<span id="selectionBoundary_1493731518682_030677381665187298" class="rangySelectionBoundary"></span></strike></u></h3>

it is same as email db

But it should not have changed tags to &lt

So it means i want to escape html. I tried

escapeHtml but did not work.

or

HtmlEscapers.htmlEscaper().escape(comment)

also we have this while putting to html

Context context = new Context(Locale.forLanguageTag("tr-TR"));
context.setVariables(comment);

and thymeleaf did not work. Converting to <td th:utext is not working.

It is happening between those

Context context = new Context(Locale.forLanguageTag("tr-TR"));

context.setVariables(mail.getParams());

String process = templateEngine.process(mail, context);

because before

Context context = new Context(Locale.forLanguageTag("tr-TR"));

there is nothing. after that line,

context.setVariables(mail.getParams());

it becoming decoded.

Community
  • 1
  • 1
mark
  • 727
  • 3
  • 14
  • 35
  • you should set the comment as innerHTML of a node on the HTML page rather than adding it as value of a text input. – MozenRath May 03 '17 at 07:57

1 Answers1

0

I think found it:

<td th:utext="${Comment}" th:remove="tag" >message ...</td>

added remove tag and utext

mark
  • 727
  • 3
  • 14
  • 35