From c09664797d164896027776783595489a547a4310 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 9 Jul 2015 08:52:42 +0200 Subject: [PATCH] some security patches and further python 2 compat Thank you Lars Bensmann --- server.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server.py b/server.py index 6013257..0e6f207 100755 --- a/server.py +++ b/server.py @@ -19,6 +19,7 @@ except ImportError: # Python 2 from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler from SocketServer import ThreadingMixIn + FileNotFoundError = IOError import sleekxmpp from sleekxmpp.componentxmpp import ComponentXMPP @@ -116,7 +117,7 @@ class HttpHandler(BaseHTTPRequestHandler): global config path = normalize_path(self.path[1:]) slashcount = path.count('/') - if slashcount < 1 or slashcount > 2: + if path[0] in ('/', '\\') or slashcount < 1 or slashcount > 2: self.send_response(404,'file not found') self.end_headers() else: @@ -139,7 +140,7 @@ class HttpHandler(BaseHTTPRequestHandler): global config path = normalize_path(self.path[1:]) slashcount = path.count('/') - if slashcount < 1 or slashcount > 2: + if path[0] in ('/', '\\') or slashcount < 1 or slashcount > 2: self.send_response(404,'file not found') self.end_headers() else: @@ -173,7 +174,7 @@ if __name__ == "__main__": server = ThreadedHTTPServer(('0.0.0.0', config['http_port']), HttpHandler) xmpp = MissingComponent(config['jid'],config['secret']) if xmpp.connect(): - xmpp.process(block=False) + xmpp.process() print("connected") server.serve_forever() else: