urlsafe_b64decoding of xml node text

kaush kaushikbarat at gmail.com
Mon Mar 3 11:50:33 EST 2008


Hi All,

I am running Apache with mod_python. A post message to my server
contains an xml of the form
<a>
    <b>(some base64 ur-safe-encoded data)</b>
</a>

I use minidom to parse the xml posted, and now try to decode the data
using the following

import minidom
import base64

decData = base64.urlsafe_b64decode(data) #data is the above mentioned
url-safe-encoded data

This line fails with the following error

Error : <type 'exceptions.TypeError'>
Error : character mapping must return integer, None or unicode
Error : <traceback object at 0x1b38e40>

If i run the same data through a script on the terminal, I am able to
successfully decode the data.

What could be the reason for this error? Can it be because of some
encoding introduced by minidom?

I think urlsafe_b64decode takes ascii string.

Thanks,
Kaushik



More information about the Python-list mailing list