Tried to fix base64 decoding in NAS for ingamesn

Examples of names that broke it before: D-9fAA**, MKIw8zC-MOwwuQ**,
MGowizB-, xXzWOP8e-w3-HCYF.
This commit is contained in:
polaris 2014-05-25 09:20:08 -04:00
parent 17e55933e1
commit 65fe2e39be

View File

@ -234,10 +234,13 @@ class NasHTTPServerHandler(BaseHTTPServer.BaseHTTPRequestHandler):
for k, v in ret.iteritems():
try:
ret[k] = base64.b64decode(v[0].replace("*", "="))
# I'm not sure about the replacement for '-', but it'll at least let it be decoded.
# For the most part it's not important since it's mostly used for the devname/ingamesn fields.
ret[k] = base64.b64decode(v[0].replace("*", "=").replace("?", "/").replace(">","+").replace("-","/"))
except TypeError:
logger.log(logging.ERROR, "Could not decode following string: ret[%s] = %s" % (k, v[0]))
logger.log(logging.ERROR, "url: %s" % str)
print "Could not decode following string: ret[%s] = %s" % (k, v[0])
print "url: %s" % str
ret[k] = v[0] # If you don't assign it like this it'll be a list, which breaks other code.
return ret