It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

replacing special chars in url

Hi,

we've got a program which is called mega plus. This software is basically web based but it doesn'T use normal http protocol. Instead, it seperates parameters using the pipe | (%7c).

Sadly, this disturbs confluence. Links to megaplus don't work unless I manually repeace those pipes with %7c.

Is there any way to do this automatically?

3 answers

That is because the pipe character ('|') is not allowed in URLs. That is why it needs to be encoded. You can read more in the standard RFC 1738.

I am afraid there is not an easy way to replace those character automatically. There is already a feature request for this in https://jira.atlassian.com/browse/CONF-12818.

Some ugly user macro to the rescue smile

## @param Url:title=Url|type=string|required=true|desc=Server name (with protocol)
## @param Query:title=Query|type=string|required=true|desc=Query (to encode)
#set ($urlEncoderClass=$content.class.forName('java.net.URLEncoder'))
#set ($stringClass=$content.class.forName('java.lang.String'))
#set ($getInstanceMethod=$urlEncoderClass.getDeclaredMethod('encode', $stringClass))
#set ($encoded=$getInstanceMethod.invoke(null, $paramQuery))
<a href="$paramUrl${encoded}">$paramUrl$paramQuery</a>

Basically, in your case you can hardcode the paramUrl parameter to make it easier to put such links (only the query string to enter, which will be encoded properly in a link, but will look as-is in link's caption)

 

that'll help thank you laugh

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published Thursday in Confluence

Confluence CVEs and common questions

Two vulnerabilities have been published for Confluence Server and Data Center recently: March 20, 2019 CVE-2019-3395 / CVE-2019-3396 April 17, 2019 CVE-2019-3398 The goal of this article is...

257 views 0 12
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you