File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,8 @@ def _extract_headers(self, environ):
84
84
85
85
return headers
86
86
87
+ SAFE_CHARS = "!$&'()*+,/:;=@%"
88
+
87
89
def _extract_url (self , environ ):
88
90
"""
89
91
Adapted from https://peps.python.org/pep-0333/#url-reconstruction
@@ -101,11 +103,15 @@ def _extract_url(self, environ):
101
103
if (scheme == "https" and port != 443 ) or (scheme != "https" and port != 80 ):
102
104
url_parts .append (f":{ port } " )
103
105
104
- url_parts .append (quote (environ .get ("SCRIPT_NAME" , "" )))
105
- url_parts .append (quote (environ .get ("PATH_INFO" ), "" ))
106
+ url_parts .append (
107
+ quote (environ .get ("SCRIPT_NAME" , "" ), safe = self .SAFE_CHARS )
108
+ )
109
+ url_parts .append (
110
+ quote (environ .get ("PATH_INFO" , "" ), safe = self .SAFE_CHARS )
111
+ )
106
112
107
113
qs = environ .get ("QUERY_STRING" )
108
114
if qs :
109
- url_parts .append (f"?{ qs } " )
115
+ url_parts .append (f"?{ quote ( qs , safe = self . SAFE_CHARS ) } " )
110
116
111
117
return "" .join (url_parts )
You can’t perform that action at this time.
0 commit comments