User Macro Indiscriminately Removes some HTML Tags from Output

William Yeack
Contributor
June 17, 2020

In my instance of Confluence, I have a simple user macro that wraps whatever is inserted into it in a div.  When I put a title and a paragraph into the content of the macro, the title is completely removed and the paragraph is stripped.  However, if I include a second paragraph, then all of the content is rendered correctly.

Here is the macro:

## Macro title: DIV
## Macro has a body: Y
## Body processing: Rendered
## Output: HTML
## @param Class:title=Class|type=string|required=false|option-showNameInPlaceholder=false|option-showValueInPlaceholder=true
## @param Style:title=Style|type=string|required=false|option-showNameInPlaceholder=false|option-showValueInPlaceholder=true
<div class="$paramClass" style="$paramStyle">$body</div>

Here is the content that I am putting into the macro:

1.png

However, when the page is saved, the output removes the title and flattens the paragraph, leaving this:

2.png

In terms of HTML, this output looks like the following:

<div class="conf-macro output-inline" style="" data-hasbody="true" data-macro-name="div">This is the content.</div>

When I add a second paragraph, then the title and both paragraphs are rendered correctly, making the HTML on the rendered page look like this:

<div class="conf-macro output-inline" style="" data-hasbody="true" data-macro-name="div"><h2 id="Contracts-Title">Title</h2><p>This is the content.</p><p>Second paragraph.</p></div>

Here is the markup from the page's source for the macro:

<ac:structured-macro ac:macro-id="1014f412-f46d-475c-8308-1ba339d8390b" ac:name="div" ac:schema-version="1">
  <ac:parameter ac:name="atlassian-macro-output-type">BLOCK</ac:parameter>
  <ac:rich-text-body>
    <h2>Title</h2>
    <p>Content</p>
  </ac:rich-text-body>
</ac:structured-macro>

I have tried removing all plugins, scripts, and styles from my Space but the behavior is the same.

Why is this simple macro changing the HTML content of its body at all let alone indiscriminately removing tags?

3 answers

1 accepted

2 votes
Answer accepted
Davin Studer
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.
June 25, 2020

There is a bug ticket for this in JAC. It is CONFSERVER-24634. Feel free to vote on it and watch the ticket and hopefully it can get fixed.

William Yeack
Contributor
June 26, 2020

I scoured Google (and I thought Atlassian's public JIRA...but maybe not) and I couldn't find this - thank you for digging it up, I'm glad to know at least that I'm not crazy!

Davin Studer
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.
June 26, 2020

Unfortunatley, it's a pretty old issue ... which does not bode well for getting fixed. But make sure to add your vote. If it gets enough votes hopefully it can get addressed.

Matt Doar
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 26, 2020

I thought I saw a workaround buried in the comments?

Davin Studer
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.
June 26, 2020

Yeah, it looks like the workaround is to have a blank paragraph inside the body of the macro ... not very elegant. I even tried doing this but no dice.

#set($body = $!body + "<p> </p>")

Looks like the header is stripped out of $body before even getting to the user macro. I verified that with the code block below which returns -1 ... meaning there is no header element in the string. : (

$body.indexOf("<h1>")
0 votes
PD Sheehan
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.
June 24, 2020

/me scratches his head

 

I did some similar testing and found the same thing. So it's consistent at least.

The one thing I found is that if you change the body to "unrendered" then the h2 tag is present.

So something happens in the rendering phase of loading the body.

Oh wow... spent some time in script runner ... totally able to replicate the exact behavior.
Check this out:

2020-06-24 23_14_04-Script Console - https___team.qad.com_plugins_servlet_scriptrunner_admin_console.png

William Yeack
Contributor
June 26, 2020

Wow that's nuts that it even does it with ScriptRunner - that's what I would have done to circumvent the rendering process but I guess that's out - 

0 votes
Dominic Lagger
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.
June 24, 2020

Hi @William Yeack 

I tried with your macro and tested a bit and have to say, I have the same error and I'm just as confused as you are.

I asked the other community leaders, whether they have a possible solution for you.

Regards, Dominic

William Yeack
Contributor
June 24, 2020

Thanks Dominic!

Suggest an answer

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

Atlassian Community Events