I am talking to a server that used to send me HTTP strings like this:
/path/to/my/handler/?action-query&id=112&type=vca&info=ch=0&type=event&ev16[sts=begin (...)
So the "info" GET parameter included "=" and "&" characters. It was rather unorthodox but nevertheless we wrote a parser for it. However, recently they have decided to encode part of it, so now the string looks like this..
/path/to/my/handler/?action=query&id=112&type=vca&info=ch%3D0%26type%3Devent%26ev46[sts%3Dbegin (...)
This breaks our parser, which expects a string like the first one.
Can I somehow "de-encode" the string, so that I can use the old code (so that it's not broken as we re-write the parser)?
As per answer below, we can use urllib.unquote() to clean the string up. However, we are relying on request.GET, which gets set up based on the first string. Is it possible to reconstruct the GET object based on the new converted string, or somehow force it to re-evaluate?
I suspect what you want is the
unquote
function from theurllib
module.Edit: I'm not very familiar with Django, but the Request and response object section of their docs states the following:
Based on my limited reading of those docs, you might be able to apply the
unquote()
function to theHttpRequest.body
attribute and build a newQueryDict
out of the results (and possibly use it to update your current one if necessary).