完美修复vim等交互式命令记录 (#236)

* fix(api) 修改建立目录的bug

使用bash代替python完成建立777目录的功能

* fix passwd input

* fix(mkdir) 修改mkdirs策略

修改原来导致的bug

* fix passwd input (#232)

修复记录敏感密码bug

* fix passwd input

* fix passwd input

* fix passwd input
pull/237/head
ibuler 2016-05-11 18:48:38 +08:00
parent d60562a034
commit 32ab8a1646
1 changed files with 9 additions and 12 deletions

View File

@ -373,15 +373,13 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
self.termlog.recoder = True self.termlog.recoder = True
self.term.input_mode = True self.term.input_mode = True
if str(jsondata['data']) in ['\r', '\n', '\r\n']: if str(jsondata['data']) in ['\r', '\n', '\r\n']:
if self.term.vim_flag: match = re.compile(r'\x1b\[\?1049', re.X).findall(self.term.vim_data)
match = re.compile(r'\x1b\[\?1049', re.X).findall(self.term.vim_data) if match:
if match: if self.term.vim_flag or len(match) == 2:
if self.term.vim_end_flag or len(match) == 2: self.term.vim_flag = False
self.term.vim_flag = False else:
self.term.vim_end_flag = False self.term.vim_flag = True
else: elif not self.term.vim_flag:
self.term.vim_end_flag = True
else:
result = self.term.deal_command(self.term.data)[0:200] result = self.term.deal_command(self.term.data)[0:200]
if len(result) > 0: if len(result) > 0:
TtyLog(log=self.log, datetime=datetime.datetime.now(), cmd=result).save() TtyLog(log=self.log, datetime=datetime.datetime.now(), cmd=result).save()
@ -424,8 +422,7 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
if not len(recv): if not len(recv):
return return
data += recv data += recv
if self.term.vim_flag: self.term.vim_data += recv
self.term.vim_data += recv
try: try:
self.write_message(data.decode('utf-8', 'replace')) self.write_message(data.decode('utf-8', 'replace'))
self.termlog.write(data) self.termlog.write(data)
@ -436,7 +433,7 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
pre_timestamp = now_timestamp pre_timestamp = now_timestamp
self.log_file_f.flush() self.log_file_f.flush()
self.log_time_f.flush() self.log_time_f.flush()
if self.term.input_mode and not self.term.is_output(data): if self.term.input_mode:
self.term.data += data self.term.data += data
data = '' data = ''
except UnicodeDecodeError: except UnicodeDecodeError: