Forums

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

replacing special chars in url

Jens Rapp
Contributor
February 2, 2015

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

1 vote
Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 2, 2015

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)

 

1 vote
Alejandro Conde Carrillo
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.
February 2, 2015

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.

0 votes
Jens Rapp
Contributor
February 5, 2015

that'll help thank you laugh

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events