Commit 93668a6c authored by Nicolas Wavrant's avatar Nicolas Wavrant

runner: escape logs before returning it

parent 038adf58
...@@ -18,6 +18,7 @@ import slapos ...@@ -18,6 +18,7 @@ import slapos
from slapos.runner.utils import (checkSoftwareFolder, configNewSR, checkUserCredential, from slapos.runner.utils import (checkSoftwareFolder, configNewSR, checkUserCredential,
createNewUser, getBuildAndRunParams, createNewUser, getBuildAndRunParams,
getProfilePath, getSlapgridResult, getProfilePath, getSlapgridResult,
html_escape,
listFolder, getBuildAndRunParams, listFolder, getBuildAndRunParams,
getProjectTitle, getRcode, updateUserCredential, getProjectTitle, getRcode, updateUserCredential,
getSlapStatus, getSvcStatus, getSlapStatus, getSvcStatus,
...@@ -244,14 +245,13 @@ def getFileLog(): ...@@ -244,14 +245,13 @@ def getFileLog():
if not os.path.exists(file_path): if not os.path.exists(file_path):
raise IOError raise IOError
if not isText(file_path): if not isText(file_path):
return jsonify(code=0, content = "Can not open binary file, please select a text file!"
result="Can not open binary file, please select a text file!")
if 'truncate' in request.form: if 'truncate' in request.form:
content = tail(open(file_path), int(request.form['truncate'])) content = tail(open(file_path), int(request.form['truncate']))
return jsonify(code=1, result=content)
else: else:
with open(file_path) as f: with open(file_path) as f:
return jsonify(code=1, result=f.read()) content = f.read()
return jsonify(code=1, result=html_escape(content))
except: except:
return jsonify(code=0, result="Warning: Log file doesn't exist yet or empty log!!") return jsonify(code=0, result="Warning: Log file doesn't exist yet or empty log!!")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment