After upgrade to 7.4.11, user macro not working with & symbol in enumValues in if conditions
Asked by Ramakrishnan Srinivasan:

Hi,

Before upgrading to 7.4.11, we had user macros with enum values as options with "\&" symbol and they were working fine. But after upgrade we observe that user macro is not working when user selects the option with \& symbol like "name\&product".

When user selects "all" enum option in the macro below, it works fine and outputs

Parameter enum option = all

**When user selects "name\&product" enum option if condition does not work and outputs in the page - "** **Parameter $PeriodQueryString" - which is not correct**

Expected output on the page is "Parameter enum option = name\&product"

Sample custom user macro is like this

```
## This is an example macro
## @param GroupByField:title=Report grouped By Fields|type=enum|enumValues=all,name&product

#if($paramGroupByField == "all")
? ?#set($PeriodQueryString=" enum option = $paramGroupByField")
#elseif($paramGroupByField == "name&product")
? ?#set($PeriodQueryString=" enum option = $paramGroupByField")
#end

Parameter $PeriodQueryString
```

Can you please let me know what could be the reason for such a changed behavior?

Thank you

with warm regards

ramki


Answers:
author: Ramakrishnan Srinivasan
body: [@Alexis Robert](/t5/user/viewprofilepage/user-id/1213386) Thank you again, I tried escaping it did not work.

I continued my attempts. This worked when I changed the line

from

```
#elseif($paramGroupByField == "name&product")
```

to

```
#elseif($paramGroupByField.replace("&amp;", "&") == "name&product")
```

added .replace("\&amp;", "\&") to the user input parameter variable.

not sure about the any other impact, atleast I can get my macros work I think.


author: Alexis Robert
body: Hi [@Ramakrishnan Srinivasan](/t5/user/viewprofilepage/user-id/2515544) ,

there could be a few reasons why your user macro stopped working.

First, to investigate this kind of issue you should start Confluence in [Safe Mode](https://confluence.atlassian.com/upm/disabling-and-enabling-apps-273875716.html) and check if the problem is still present.

Then I would activate one by one the addons, because there might be a conflict with a specific new version that prevents your user macro from working.

Let me know if this helps,

--Alexis

comments: author: Ramakrishnan Srinivasan
body: Hi [@Alexis Robert](/t5/user/viewprofilepage/user-id/1213386) Thank you for the response. I will try that in my staging setup, but do you think that the problem not recognizing enumValue option with "\&" can arise from other add-ons. My knowledge here is limited so please bear with me for this very basic question.

Also, I found that if I change the option from "name\&product" to "name-product", the macro starts working. So, I think somewhere "\&" symbol in velocity template lost its characteristic.


author: Alexis Robert
body: There might be a change in how Confluence handles special characters, it's hard to say since a lot of stuff is updated between two releases, even internal components can have an impact on this kind of stuff.

In your case it might be just this : an update somewhere that prevents using special characters, so maybe switching from "\&" to "-" is the solution here !

Maybe you can try esacaping the character, like this : "\\\&" ?


Tags: confluence-server

server