[oXygen-user] URI Handler Question: Escaping/Unescaping URIs

Dan Caprioara
Tue Nov 6 01:23:16 CST 2007


The best thing to do is to escape your URLs before using it in your data 
structures. To make the escaping compatible with oXygen, you should use 
the ro.sync.util.URLUtil class (from the oxygen.jar). Example:

In your chooseURL() method:

URL url = URLUtil.correct(new URL(urlString));
 
The reverse method is URLUtil.uncorrect();

If you need more info, please let me know.

Best regards,
Dan


Eliot Kimber wrote:
> I don't know if anything I'm doing here is correct, but here's what I'm
> trying to do:
>
> In my plugin I'm producing URIs that look like this:
>
> RSUITE:/Some Path/Another Folder/Some File Name With Spaces?moid=123
>
> I was doing this in my chooseURL() method:
>
> Return url = new URL(urlString);
>
> Where "urlString" would be the string above (that is, the string with spaces
> unescaped).
>
> The problem I ran into was that on close the URL that came back had all the
> spaces escaped so that the URL produced by chooseURL() and the one used by
> getOutputStream() did not compare as equal (which was a problem because I
> was using the URL as a key to get back to my private data structures
> representing the repository object).
>
> I solved the problem by doing this:
>
> urlString = RSUITE_PROTOCOL + ":" + URLEncoder.encode(resId, "utf-8");
>
> urlString = urlString.replaceAll("\\+", "%20");
>
>
> Where "resId" is the part of the URL following the "RSUITE:.
>
> This works in my (limited) tests but I don't think it's a complete solution.
>
> My question is: is there a better way to be escaping and unscaping the URI
> string so that what Oxygen calls getOutputStream() on matches what I
> originally construct.
>
> The other thing I noticed was that if I didn't change the "+" to "%20" then
> in the Oxygen UI the "+" characters show up (e.g., in the label on the tab
> for the document) but if I change them to "%20" then you get spaces, which
> is what I want.
>
> What is the right/best way to handle the escaping and unescaping in this
> environment?
>
> Thanks,
>
> Eliot
>
>   



More information about the oXygen-user mailing list