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

Eliot Kimber
Mon Nov 5 16:36:49 CST 2007


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

-- 
W. Eliot Kimber
Senior Solutions Architect
Really Strategies, Inc.
"Bringing Strategy, Content, and Technology Together"
Main: 610.631.6770
www.reallysi.com
www.rsuitecms.com

Sent using the Microsoft Entourage 2004 for Mac Test Drive.





More information about the oXygen-user mailing list