Usage of param type confluence-content in macro for pages with a semicolon in the Title

Hello there

We use a macro that creates a fully customizable button on a page that points to another page in confluence. To select the page, I use the parameter type “confluence-content”:

## @param link:title=Targetpage|type=confluence-content|required=true|desc=Some confluence page

Later I generate a link out of it using the following code:

#set ($containerManagerClass=$content.class.forName('com.atlassian.spring.container.ContainerManager'))
#set ($getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null))
#set ($containerManager=$getInstanceMethod.invoke(null,null))
#set ($containerContext=$containerManager.containerContext)
#set ($pageManager=$containerContext.getComponent('pageManager'))
#set ($ss='')
#set ($sp='')

#foreach ($p in $paramlink.split(":"))
#if ($ss=='')
#set ($ss=$p)
#else
#set ($sp=$p)
#end
#end
#if ($sp=='')
#set ($sp=$ss)
#set ($ss=$space.key)
#end

#set ($page=$pageManager.getPage($ss, $sp))


<div style="text-align: center;" onclick="location.href='$req.contextPath$page.urlPath'";>$paramlink</div>

This works fine until the page title contains a semicolon (’ or “& # 39 ;” for java). If this is the case, the var “$page” is empty and so no page is found.

I can’t figure out how to get this working again and any help would be appreciated!

Thanks a lot
nks

It seems that I just found the answer myself.

If I add the following line just before the “foreach” part and change this a little bit, it seems to work now.

...
#set($newlink = $paramlink.replace("&#39;", "'"))

foreach ($p in $newlink.split(":"))
...