aboutsummaryrefslogtreecommitdiff
path: root/fuss.py
diff options
context:
space:
mode:
Diffstat (limited to 'fuss.py')
-rw-r--r--fuss.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/fuss.py b/fuss.py
index d3f915e..b67cbef 100644
--- a/fuss.py
+++ b/fuss.py
@@ -21,7 +21,7 @@ from flask_script import Manager, Server # python3-flask-script
import magic # python3-magic, see below
from hashlib import sha256
from mimetypes import guess_extension
-import os, sys, time, json, base64
+import os, sys, time, json, base64, re
from datetime import datetime, date
from uwsgidecorators import * # python3-uwsgidecorators
from logging.config import dictConfig
@@ -48,6 +48,9 @@ def trim_dict(a,max_length=40):
b[i] = a[i]
return b
+def normalize(instring):
+ return re.sub("//","/",instring)
+
# load config file
# Load it from the current directory, which is not FHS-compliant
#conf_file = os.path.join(os.path.dirname(os.path.realpath(__file__)),"fuss.conf")
@@ -266,9 +269,10 @@ def print_files(path=None,format="text",header=False):
_server = "http://" + request.headers["Host"]
try:
_prefix = request.headers["X-Forwarded-Prefix"]
+ #app.logger.warn("This is x-forwarded-prefix: {0}".format(request.headers["X-Forwarded-Prefix"])) # REMOVEME
_temp = _prefix.replace(", ", "\n").split('\n')
- if len(_temp) > 1:
- _prefix = _temp[0]
+ _temp = normalize("/".join(_temp))
+ _prefix = _temp
except:
_prefix = "/"
app.logger.warn("Failed to get x-forwarded-prefix")
@@ -453,9 +457,10 @@ def html_template(filename="",full=False):
_server = "http://" + request.headers["Host"]
try:
_prefix = request.headers["X-Forwarded-Prefix"]
+ #app.logger.warn("This is x-forwarded-prefix: {0}".format(request.headers["X-Forwarded-Prefix"])) # REMOVEME
_temp = _prefix.replace(", ", "\n").split('\n')
- if len(_temp) > 1:
- _prefix = _temp[0]
+ _temp = normalize("/".join(_temp))
+ _prefix = _temp
except:
_prefix = "/"
if full:
bgstack15