'Apereo CAS spaces not allowed in serviceUrl using %20 or +

We are trying to validate a service using CAS 6.5, with a similar url than : https://example.com/folder 1/folder 2/

As you can see, there are some spaces in the url, so we encode the url. We have tried both encodings for spaces (%20 and +) with similar results in cas log:

caused by: java.net.URISyntaxException: Illegal character in path at index ....
at java.net.URI$Parser.fail(Unknown Source) ~[?:?]
    at java.net.URI$Parser.checkChars(Unknown Source) ~[?:?]
    at java.net.URI$Parser.parseHierarchical(Unknown Source) ~[?:?]
    at java.net.URI$Parser.parse(Unknown Source) ~[?:?]
    at java.net.URI.<init>(Unknown Source) ~[?:?]
    at org.apache.http.client.utils.URIBuilder.<init>(URIBuilder.java:82) 

CAS receives the url encoded (using %20 or +) and decode it as spaces. When CAS tries to validate the url, it is using URIBuilder which fails when there are spaces in the middle.

I've checked CAS doc about the urls used in the parameters, and it specifies that they should be url encoded, so the "special" characters will not fail, but in the case of the spaces, it seems that is failing.

Is there any way to bypass this? I couldn't find any bug ticket or any mention about if the urls with spaces are supported or not.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source