Special character escape

Unanswered Question
Oct 1st, 2008
User Badges:

i want to put a http request inside the <URL> tag. i am able to replace those & to (& a m p) . But how can i escape a space? i have tried + or %20 or (& s n b p) but none of these work :(


  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 0 (0 ratings)
Loading.
stephan.steiner Thu, 10/02/2008 - 01:09
User Badges:
  • Silver, 250 points or more

I would never use URLs with spaces but that's just me.. it's just asking for trouble.


If you do no special handling, what is shown when you access the service from a webbrowser? And what does the phone do if you push a softkey that has an url with spaces in it? where does it send the request?


I recently had to deal with the reverse situation.. service urls and service parameters. Looking at what the phone sends to my app I've been able to determine that a service url with query strings needs the urlencoding escaping (%20) whereas service parameters don't need any special handling and get to my app the way I intended. In fact.. the query string part is similar to what you want.. the phone will make a request to the callmanager which returns a CiscoIPPHoneMenu page containing the subscribed services and service urls.. thus, if you sniff that traffic and use a service url that contains a space (encoded with %20) you'll see what the phone gets and you then need to replicate that for your own app (I suppose the url itself would need %20 escaping as well as the query strings but who knows).

stephan.steiner Thu, 10/02/2008 - 04:32
User Badges:
  • Silver, 250 points or more

Hmm.. no post editing? I actually ran into the same problem now.. and I'm beginning to think it's a fault in the phone. I only have an IPC right now which isn't the best device for testing but I think it should do the url encoding from the xml.. like a browser does (I can launch my app just fine when calling the urls from the browser).


However, I have my own class library that writes the xml code for the CiscoIPPhoneObject and when I replaced my standard xml encoding block to an encoding block which after standard xml encoding does a

retval.replace(" ", "%20")

then the phone merrily makes a request to the proper url. I only have to validate that on the hardphones now. I will report back once I've done that.

leozleung Thu, 10/02/2008 - 19:13
User Badges:

I am able to make a request through browser too. But the phone show unusual behaviour when i access the URL which contains space, %20 or +. "host not found" will be shown on the prompt bar. But when i remove them, the phone can make a request normally.


I will try with a hardphone as soon as it is ready. I will report if there is any news.

stephan.steiner Thu, 10/02/2008 - 23:37
User Badges:
  • Silver, 250 points or more

Hmm.. so you are using the IPC, too? Which version? I have the latest and as I write.. it works with %20. What you have to be careful though is that you need to do this change at the appropriate place and using the appropriate means. For instance.. initially I used the URLEncoder with UTF-8 character set.. this turns space into a +. Then that string is sent to my class that generates the XML for the CiscoIPPhone* elements, which in turn performs a search and replace for the 6 characters that need XML encoding.. and somewhere in betwen the encoding bit was removed again. So now I have code in place for each url element which first xml encodes the url, then does a search and replace for space and replaces it with a %20 and finally I cut off the url at the appropriate length if applicable (of course that would create problems if it ever happens.. but the xml cannot even be rendered if you don't cut off strings at the appropriate position).


Next week I'll test how my hardphones like that approach.

leozleung Fri, 10/03/2008 - 01:11
User Badges:

yes i was using IPC version 2.1.1. However i have no luck with 2.1.4 version too :(

however i am confused with "first xml encodes the url, then does a search and replace for space and replaces it with a %20". what you mean is encode the URL 2 time? but why so? isnt after the first time encoding, all the spaces will be encoded?


Actions

This Discussion