Skip to content

Commit a846b76

Browse files
committed
move utilities library and actually use it
1 parent e447d85 commit a846b76

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Diff for: plugin/controllers/file.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
from Components.config import config
2121
from Tools.Directories import fileExists
22+
from utilities import lenient_force_utf_8, sanitise_filename_slashes
23+
2224

2325
def new_getRequestHostname(self):
2426
host = self.getHeader(b'host')
@@ -38,8 +40,8 @@ def render(self, request):
3840
action = request.args["action"][0]
3941

4042
if "file" in request.args:
41-
filename = request.args["file"][0].decode('utf-8', 'ignore').encode('utf-8')
42-
filename = re.sub("^/+", "/", os.path.realpath(filename))
43+
filename = lenient_force_utf_8(request.args["file"][0])
44+
filename = sanitise_filename_slashes(os.path.realpath(filename))
4345

4446
if not os.path.exists(filename):
4547
return "File '%s' not found" % (filename)

Diff for: plugin/controllers/rest_fs_access.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,9 @@
4343
import twisted.web.static
4444
from twisted.web import http
4545

46+
from utilities import MANY_SLASHES_REGEX
4647
import file
4748

48-
MANY_SLASHES_PATTERN = r'[\/]+'
49-
MANY_SLASHES_REGEX = re.compile(MANY_SLASHES_PATTERN)
50-
5149
#: default path from which files will be served
5250
DEFAULT_ROOT_PATH = os.path.abspath(os.path.dirname(__file__))
5351

File renamed without changes.

0 commit comments

Comments
 (0)