mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
(Maybe) fix potential code injection attack
This commit is contained in:
parent
eba7bff050
commit
75fb8fc920
@ -9,6 +9,7 @@ import base64
|
|||||||
import socket
|
import socket
|
||||||
import random
|
import random
|
||||||
import logging
|
import logging
|
||||||
|
import html
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from socket import gethostname
|
from socket import gethostname
|
||||||
@ -455,17 +456,19 @@ class Helpers:
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_tree(folder, html=""):
|
def generate_tree(folder, output=""):
|
||||||
for filename in os.listdir(folder):
|
for filename in os.listdir(folder):
|
||||||
|
print(filename)
|
||||||
|
filename = html.escape(filename)
|
||||||
print(filename)
|
print(filename)
|
||||||
rel = os.path.join(folder, filename)
|
rel = os.path.join(folder, filename)
|
||||||
if os.path.isdir(rel):
|
if os.path.isdir(rel):
|
||||||
html += '<li>\n<span class="tree-caret">{}</span>\n<ul class="tree-nested">'.format(filename)
|
output += '<li>\n<span class="tree-caret">{}</span>\n<ul class="tree-nested">'.format(filename)
|
||||||
html += helper.generate_tree(rel)
|
output += helper.generate_tree(rel)
|
||||||
html += '</ul>\n</li>'
|
output += '</ul>\n</li>'
|
||||||
else:
|
else:
|
||||||
html += '<li>{}</li>'.format(filename)
|
output += '<li>{}</li>'.format(filename)
|
||||||
return html
|
return output
|
||||||
|
|
||||||
|
|
||||||
helper = Helpers()
|
helper = Helpers()
|
||||||
|
Loading…
Reference in New Issue
Block a user