commit ad12876b0c6b9f1aaaf8eafd6c7765dc2efeba83
parent 58feb5e76bb8c3fa88613283de8abd748995c57f
Author: Sheng <webmaster0115@gmail.com>
Date: Tue, 28 Aug 2018 20:25:07 +0800
Strip encoding
Diffstat:
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/sshserver.py b/tests/sshserver.py
@@ -51,7 +51,7 @@ class Server(paramiko.ServerInterface):
b'UWT10hcuO4Ks8=')
good_pub_key = paramiko.RSAKey(data=decodebytes(data))
- encodings = ['UTF-8', 'GBK']
+ encodings = ['UTF-8', 'GBK', 'UTF-8\r\n', 'GBK\r\n']
def __init__(self):
self.shell_event = threading.Event()
@@ -146,7 +146,7 @@ def run_ssh_server(port=2200, running=True):
# chan.send('\r\n\r\nWelcome!\r\n\r\n')
print(server.encoding)
- chan.send(banner.encode(server.encoding))
+ chan.send(banner.encode(server.encoding.strip()))
if username == 'bar':
msg = chan.recv(1024)
chan.send(msg)
diff --git a/webssh/handler.py b/webssh/handler.py
@@ -173,7 +173,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
except paramiko.SSHException:
result = None
else:
- result = to_str(stdout.read())
+ result = to_str(stdout.read().strip())
return result if result else 'utf-8'