mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
Improve target url validation
In addition to checking for scheme='http', we should also check that netloc has a value. There are many meaningless URLs that pass the current check. For instance: ``` In [5]: urlparse("http://") Out[5]: ParseResult(scheme='http', netloc='', path='', params='', query='', fragment='') In [6]: urlparse("http:///") Out[6]: ParseResult(scheme='http', netloc='', path='/', params='', query='', fragment='') ``` netloc should always have a value.
This commit is contained in:
parent
38d6e4337d
commit
16489b99d9
@ -233,7 +233,7 @@ class MitmProxyHandler(http_server.BaseHTTPRequestHandler):
|
|||||||
else:
|
else:
|
||||||
self.url = self.path
|
self.url = self.path
|
||||||
u = urllib_parse.urlparse(self.url)
|
u = urllib_parse.urlparse(self.url)
|
||||||
if u.scheme != 'http':
|
if u.scheme != 'http' or u.netloc == '':
|
||||||
raise Exception(
|
raise Exception(
|
||||||
'unable to parse request %r as a proxy request' % (
|
'unable to parse request %r as a proxy request' % (
|
||||||
self.requestline))
|
self.requestline))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user