punyencode only the host part of the URL. Fixes #7981
This commit is contained in:
parent
b7c6d3e1b5
commit
c2ac09cce2
2 changed files with 11 additions and 2 deletions
|
@ -36,6 +36,7 @@ import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import urllib
|
import urllib
|
||||||
import urllib
|
import urllib
|
||||||
|
from urlparse import urlparse
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import errno
|
import errno
|
||||||
import select
|
import select
|
||||||
|
@ -137,6 +138,14 @@ def ascii_to_idn(host):
|
||||||
converted_labels.append(idna.ToUnicode(label))
|
converted_labels.append(idna.ToUnicode(label))
|
||||||
return ".".join(converted_labels)
|
return ".".join(converted_labels)
|
||||||
|
|
||||||
|
def puny_encode_url(url):
|
||||||
|
_url = url
|
||||||
|
if '//' not in _url:
|
||||||
|
_url = '//' + _url
|
||||||
|
o = urlparse(_url)
|
||||||
|
p_loc = idn_to_ascii(o.netloc)
|
||||||
|
return url.replace(o.netloc, p_loc)
|
||||||
|
|
||||||
def parse_resource(resource):
|
def parse_resource(resource):
|
||||||
"""
|
"""
|
||||||
Perform stringprep on resource and return it
|
Perform stringprep on resource and return it
|
||||||
|
|
|
@ -1218,8 +1218,8 @@ class ConversationTextview(GObject.GObject):
|
||||||
all_tags = [(ttt.lookup(t) if isinstance(t, str) else t) for t in all_tags]
|
all_tags = [(ttt.lookup(t) if isinstance(t, str) else t) for t in all_tags]
|
||||||
buffer_.insert_with_tags(end_iter, special_text, *all_tags)
|
buffer_.insert_with_tags(end_iter, special_text, *all_tags)
|
||||||
if 'url' in tags:
|
if 'url' in tags:
|
||||||
puny_text = puny_encode(special_text).decode('utf-8')
|
puny_text = helpers.puny_encode_url(special_text)
|
||||||
if not puny_text.endswith('-'):
|
if puny_text != special_text:
|
||||||
puny_tags = []
|
puny_tags = []
|
||||||
if use_other_tags:
|
if use_other_tags:
|
||||||
puny_tags += other_tags
|
puny_tags += other_tags
|
||||||
|
|
Loading…
Add table
Reference in a new issue