Catch exceptions on invalid URLs
Closes #8494 Conflicts: src/common/helpers.py
This commit is contained in:
parent
5716efde68
commit
d129abbed6
|
@ -143,8 +143,12 @@ def puny_encode_url(url):
|
|||
_url = url
|
||||
if '//' not in _url:
|
||||
_url = '//' + _url
|
||||
o = urllib.parse.urlparse(_url)
|
||||
p_loc = idn_to_ascii(o.netloc)
|
||||
try:
|
||||
o = urllib.parse.urlparse(_url)
|
||||
p_loc = idn_to_ascii(o.netloc)
|
||||
except Exception:
|
||||
log.debug('urlparse failed: %s', url)
|
||||
return False
|
||||
return url.replace(o.netloc, p_loc)
|
||||
|
||||
def parse_resource(resource):
|
||||
|
|
|
@ -1232,6 +1232,8 @@ class ConversationTextview(GObject.GObject):
|
|||
puny_tags = []
|
||||
if use_other_tags:
|
||||
puny_tags += other_tags
|
||||
if not puny_text:
|
||||
puny_text = _('Invalid URL')
|
||||
puny_tags = [(ttt.lookup(t) if isinstance(t, str) else t) for t in puny_tags]
|
||||
buffer_.insert_with_tags(end_iter, " (%s)" % puny_text, *puny_tags)
|
||||
|
||||
|
|
Loading…
Reference in New Issue