Question

When passing an URL to the Application by the use of jnlp , System.getProperty fails to retrieve value if that value contains a percent (%).

Example that returns null:

<property name="jnlp.url" value="https://www.site.se/Register%20customer.aspx" />

Example that returns correct url:

<property name="jnlp.url" value="https://www.site.se/Register20customer.aspx" />

Is this a security thing, xml-based or just bad encoding?

Is there some escaping i can do or should i just go with an old switcheroo (% -> &#37; -> % or similar)?

Was it helpful?

Solution

I solved this using a workaround by Base64 encoding the strings.

Basically when generating the jnlp file (PHP):

<property name="<?=$key?>" value="<?=base64_encode($value)?>" />

And then in the application:

import org.apache.commons.net.util.Base64;
...
jnlpURL  = deBase64(System.getProperty("jnlp.url"));
...
private String deBase64(String str)
{
    if (Base64.isArrayByteBase64(str.getBytes())) {
        return new String(Base64.decodeBase64(str));
    } else {
        return str;
    }
}

This does not solve the original issue why it returns null, but provides a way to circumvent that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top