Skip to content

Commit 2ae398f

Browse files
consideRatiooeway
andcommitted
Quote as little as needed for a valid proxied web request
Co-authored-by: Wei Ouyang <oeway007@gmail.com>
1 parent 315d029 commit 2ae398f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

jupyter_server_proxy/handlers.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,14 @@ def get_client_uri(self, protocol, host, port, proxied_path):
141141
else:
142142
client_path = proxied_path
143143

144-
client_path = quote(client_path)
144+
# Quote spaces, åäö and such, but only enough to send a valid web
145+
# request onwards. To do this, we mark the RFC 3986 specs' "reserved"
146+
# and "un-reserved" characters as safe that won't need quoting. The
147+
# un-reserved need to be marked safe to ensure the quote function behave
148+
# the same in py36 as py37.
149+
#
150+
# ref: https://tools.ietf.org/html/rfc3986#section-2.2
151+
client_path = quote(client_path, safe=":/?#[]@!$&'()*+,;=-._~")
145152

146153
client_uri = '{protocol}://{host}:{port}{path}'.format(
147154
protocol=protocol,

0 commit comments

Comments
 (0)