forked from solderpunk/AV-98
Fix cross-domain redirect warning, and add cross-protocol redirect warning.
This commit is contained in:
parent
088c415987
commit
5187e75566
8
av98.py
8
av98.py
|
@ -417,18 +417,20 @@ Slow internet connection? Use 'set timeout' to be more patient.""")
|
||||||
new_gi = GeminiItem(gi.absolutise_url(meta))
|
new_gi = GeminiItem(gi.absolutise_url(meta))
|
||||||
if new_gi.url in self.previous_redirectors:
|
if new_gi.url in self.previous_redirectors:
|
||||||
print("Error: caught in redirect loop!")
|
print("Error: caught in redirect loop!")
|
||||||
|
return
|
||||||
elif len(self.previous_redirectors) == _MAX_REDIRECTS:
|
elif len(self.previous_redirectors) == _MAX_REDIRECTS:
|
||||||
print("Error: refusing to follow more than %d consecutive redirects!" % _MAX_REDIRECTS)
|
print("Error: refusing to follow more than %d consecutive redirects!" % _MAX_REDIRECTS)
|
||||||
|
return
|
||||||
# Never follow cross-domain redirects without asking
|
# Never follow cross-domain redirects without asking
|
||||||
elif new_gi.host != gi.host:
|
elif new_gi.host != gi.host:
|
||||||
follow = input("Follow cross-domain redirect to %s? (y/n) " % new_gi.url)
|
follow = input("Follow cross-domain redirect to %s? (y/n) " % new_gi.url)
|
||||||
if follow.strip().lower() not in ("y", "yes"):
|
# Never follow cross-protocol redirects without asking
|
||||||
return
|
elif new_gi.scheme != gi.scheme:
|
||||||
|
follow = input("Follow cross-protocol redirect to %s? (y/n) " % new_gi.url)
|
||||||
elif not self.options["auto_follow_redirects"]:
|
elif not self.options["auto_follow_redirects"]:
|
||||||
follow = input("Follow redirect to %s? (y/n) " % new_gi.url)
|
follow = input("Follow redirect to %s? (y/n) " % new_gi.url)
|
||||||
if follow.strip().lower() not in ("y", "yes"):
|
if follow.strip().lower() not in ("y", "yes"):
|
||||||
return
|
return
|
||||||
else:
|
|
||||||
self._debug("Following redirect to %s." % new_gi.url)
|
self._debug("Following redirect to %s." % new_gi.url)
|
||||||
self._debug("This is consecutive redirect number %d." % len(self.previous_redirectors))
|
self._debug("This is consecutive redirect number %d." % len(self.previous_redirectors))
|
||||||
self.previous_redirectors.add(gi.url)
|
self.previous_redirectors.add(gi.url)
|
||||||
|
|
Loading…
Reference in New Issue