Skip to content

Commit

Permalink
move utilities library and actually use it
Browse files Browse the repository at this point in the history
  • Loading branch information
doubleO8 committed Sep 9, 2017
1 parent e447d85 commit a846b76
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 4 additions & 2 deletions plugin/controllers/file.py
Expand Up @@ -19,6 +19,8 @@

from Components.config import config
from Tools.Directories import fileExists
from utilities import lenient_force_utf_8, sanitise_filename_slashes


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

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

if not os.path.exists(filename):
return "File '%s' not found" % (filename)
Expand Down
4 changes: 1 addition & 3 deletions plugin/controllers/rest_fs_access.py
Expand Up @@ -43,11 +43,9 @@
import twisted.web.static
from twisted.web import http

from utilities import MANY_SLASHES_REGEX
import file

MANY_SLASHES_PATTERN = r'[\/]+'
MANY_SLASHES_REGEX = re.compile(MANY_SLASHES_PATTERN)

#: default path from which files will be served
DEFAULT_ROOT_PATH = os.path.abspath(os.path.dirname(__file__))

Expand Down
File renamed without changes.

0 comments on commit a846b76

Please sign in to comment.