The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Confluence: How to escape double quotes in user macros?

Daniela Scheiwe
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 Champions.
January 2, 2013

Hi,

I'm writing a lot of user macros and stumble upon this one problem every now and then:

I have no idea how to escape double quotes properly. In this specific case I'm writing a macro that holds Bob Swifts run&cli plugins, where quotes are needed. Here's a code example:

#set($globalHelper = $action.getHelper())

#set ($update = $globalHelper.renderConfluenceMacro("{run:replace=status:green:Lorem ipsum?:radio::green::yellow::red|titleRun=lorem!}
{cli:profile=confluence|hideOutput=false}
--action storePage --space xxx --title "yyy" --content "zzz"
{cli}
Status aktualisiert.
{run}
"))

The part within the {cli-stuff makes the problems.

I tried single quotes, escaping with backslash...even HTML entities, nothing is working properly. With quotes like above I get an error message when using the macro (of course), when escaping the values are set exactly with the chars I used to escape.

I'm really hoping there's a solution for this :)

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

3 votes
Answer accepted
Kirstin Seidel-Gebert
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 Champions.
January 6, 2013

Hello Superuschi,

I stumbled into the same problem today and found that: http://mail-archives.apache.org/mod_mbox/velocity-user/200311.mbox/%3C3FC29041.3000000@gmx.de%3E

Thus, I solved my problem by introducing a constant containing the quote character

#set( $q = '"' )

and using it like that:

#set( $style = "style=${q}$paramStyle${q}" )

Hope that helps.

Matthew Gorton
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 13, 2013

Kirstin,

Your solution also worked for me. I needed to expand a file name using a user supplied variable but the period and suffix were causing problems. Ther period needed to be separated from the variable name by whitespace or the variable would not be replaced witht the user supplied value :-(

I used this technique to create a suffix variable that was set to ".rss" and then my macro worked like a charm.

Cheers

Kirstin Seidel-Gebert
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 Champions.
March 13, 2013

Nice to hear that, Matthew.

0 votes
Daniela Scheiwe
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 Champions.
January 6, 2013

Okay, I figured that in this case, I can just use no quotes at all in the cli-part. Won't work in other cases though.

TAGS
AUG Leaders

Atlassian Community Events