From 6b42d787a7a591a882792d370622c81202531e26 Mon Sep 17 00:00:00 2001 From: rr- Date: Sat, 21 Jan 2017 00:12:28 +0100 Subject: [PATCH] server: fix problems with escaping --- INSTALL.md | 5 +++-- client/js/util/uri.js | 4 ++-- server/szurubooru/rest/app.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index c4ccdcc..1b3ebba 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -159,13 +159,14 @@ the one in the `config.yaml`, so that client knows how to access the backend! server { listen 80; server_name great.dude; - merge_slashes off; # to support post tags such as /// location ~ ^/api$ { return 302 /api/; } location ~ ^/api/(.*)$ { - proxy_pass http://127.0.0.1:6666/$1$is_args$args; + if ($request_uri ~* "/api/(.*)") { # preserve PATH_INFO as-is + proxy_pass http://127.0.0.1:6666/$1; + } } location / { root /home/rr-/src/maintained/szurubooru/client/public; diff --git a/client/js/util/uri.js b/client/js/util/uri.js index 52e90a0..a048228 100644 --- a/client/js/util/uri.js +++ b/client/js/util/uri.js @@ -24,11 +24,11 @@ function formatApiLink(...values) { } function escapeParam(text) { - return encodeURIComponent(text).replace(/%/g, '$'); + return encodeURIComponent(text); } function unescapeParam(text) { - return decodeURIComponent(text.replace(/\$/g, '%')); + return decodeURIComponent(text); } function formatClientLink(...values) { diff --git a/server/szurubooru/rest/app.py b/server/szurubooru/rest/app.py index 0823e6e..b4d23d4 100644 --- a/server/szurubooru/rest/app.py +++ b/server/szurubooru/rest/app.py @@ -31,7 +31,7 @@ def _get_headers(env): def _create_context(env): method = env['REQUEST_METHOD'] - path = urllib.parse.unquote('/' + env['PATH_INFO'].lstrip('/')) + path = '/' + env['PATH_INFO'].lstrip('/') headers = _get_headers(env) files = {}