File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -350,6 +350,14 @@ def full_url(self):
350
350
def full_url (self , url ):
351
351
# unwrap('<URL:type://host/path>') --> 'type://host/path'
352
352
self ._full_url = _unwrap (url )
353
+ # Sanity check self._full_url to avoid control characters in HTTP.
354
+ # https://bugs.python.org/issue14826
355
+ # https://bugs.python.org/issue36276
356
+ # The same control characters check was adopted by Golang in:
357
+ # https://go-review.googlesource.com/c/go/+/159157
358
+ if (self ._full_url .startswith ('http' ) and
359
+ re .search ("[\x00 - \x7f -\x9f ]" , self ._full_url )):
360
+ raise ValueError ("URL can't contain control characters. %r" % (self ._full_url ,))
353
361
self ._full_url , self .fragment = _splittag (self ._full_url )
354
362
self ._parse ()
355
363
You can’t perform that action at this time.
0 commit comments