user macro failes

Sara von Hofsten February 26, 2024

 

 

Hello,

this user macro, that I posted a picture of below, suddenly stopped working and is only displaying  $htmlUtil.htmlEncode($content.displayTitle)

I can't seem to fix it. I think this happend after the last patch of Confluence to version 8.5.4.

How can I fix it? We use this macro a lot in our organization.

 

Skärmbild 2024-02-26 132938.png

 

 

 

 

 

 

1 answer

0 votes
Andrii Maliuta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2024

Hello @Sara von Hofsten ,

I can see that HtmlUtil should be available in velocity context according to the docs: https://developer.atlassian.com/server/confluence/confluence-objects-accessible-from-velocity, but really, it is not.

As an option, if HTML is rendered with a variable assignment, the variable name needs to end with "Html". This will render HTML instead of escaping it.

Example: $outputHtml instead of $output

So you can try to create the variable with the title ending with 'html' to be escaped, like:

#set($titleHtml = $content.displayTitle )
$content.displayTitle ## as is
<br>
$titleHtml ## escaped
<br>

https://confluence.atlassian.com/doc/user-macro-template-syntax-223906130.html

 

Sara von Hofsten February 27, 2024

adding HtmlUtil to string in setenv.sh fixed the html problem.

The macro output looks correct but there's some problem with the lik to parent page. I get page not found or insufficient permission error, but i guess it's a macro problem and not a server problem :)

Like Andrii Maliuta likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.5.4
TAGS
AUG Leaders

Atlassian Community Events