From 65fe2e39be5780b807d0959f6ed71b3ff25b0394 Mon Sep 17 00:00:00 2001 From: polaris Date: Sun, 25 May 2014 09:20:08 -0400 Subject: [PATCH] Tried to fix base64 decoding in NAS for ingamesn Examples of names that broke it before: D-9fAA**, MKIw8zC-MOwwuQ**, MGowizB-, xXzWOP8e-w3-HCYF. --- nas_server.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/nas_server.py b/nas_server.py index 94edcc2..34e5e69 100644 --- a/nas_server.py +++ b/nas_server.py @@ -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