From b43bd58f22bfbec17b3e935b97fd14b2392a3962 Mon Sep 17 00:00:00 2001 From: Sam Wenham Date: Sun, 24 Feb 2019 19:50:45 +0000 Subject: [PATCH] Decode the url encoded # when looking at wallets --- core/view_surveys.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/view_surveys.py b/core/view_surveys.py index 0e958c7..aad48c3 100644 --- a/core/view_surveys.py +++ b/core/view_surveys.py @@ -6,6 +6,7 @@ import os, stat import re from troggle.core.models import SurvexScansFolder, SurvexScanSingle, SurvexBlock, TunnelFile import parsers.surveys +import urllib # inline fileabstraction into here if it's not going to be useful anywhere else # keep things simple and ignore exceptions everywhere for now @@ -17,7 +18,7 @@ def getMimeType(extension): "html": "text/html", }[extension] except: - print "unknown file type" + print("unknown file type") return "text/plain" @@ -166,11 +167,11 @@ def jgtuploadfile(request): def surveyscansfolder(request, path): #print [ s.walletname for s in SurvexScansFolder.objects.all() ] - survexscansfolder = SurvexScansFolder.objects.get(walletname=path) + survexscansfolder = SurvexScansFolder.objects.get(walletname=urllib.unquote(path)) return render_to_response('survexscansfolder.html', { 'survexscansfolder':survexscansfolder, 'settings': settings }) def surveyscansingle(request, path, file): - survexscansfolder = SurvexScansFolder.objects.get(walletname=path) + survexscansfolder = SurvexScansFolder.objects.get(walletname=urllib.unquote(path)) survexscansingle = SurvexScanSingle.objects.get(survexscansfolder=survexscansfolder, name=file) return HttpResponse(content=open(survexscansingle.ffile), content_type=getMimeType(path.split(".")[-1])) #return render_to_response('survexscansfolder.html', { 'survexscansfolder':survexscansfolder, 'settings': settings }) @@ -186,12 +187,12 @@ def tunneldata(request): def tunnelfile(request, path): - tunnelfile = TunnelFile.objects.get(tunnelpath=path) + tunnelfile = TunnelFile.objects.get(tunnelpath=urllib.unquote(path)) tfile = os.path.join(settings.TUNNEL_DATA, tunnelfile.tunnelpath) return HttpResponse(content=open(tfile), content_type="text/plain") def tunnelfileupload(request, path): - tunnelfile = TunnelFile.objects.get(tunnelpath=path) + tunnelfile = TunnelFile.objects.get(tunnelpath=urllib.unquote(path)) tfile = os.path.join(settings.TUNNEL_DATA, tunnelfile.tunnelpath) project, user, password, tunnelversion = request.POST["tunnelproject"], request.POST["tunneluser"], request.POST["tunnelpassword"], request.POST["tunnelversion"]