Commit c2ac09cc authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

punyencode only the host part of the URL. Fixes #7981

parent b7c6d3e1
......@@ -36,6 +36,7 @@ import os
import subprocess
import urllib
import urllib
from urlparse import urlparse
import webbrowser
import errno
import select
......@@ -137,6 +138,14 @@ def ascii_to_idn(host):
converted_labels.append(idna.ToUnicode(label))
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):
"""
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]
buffer_.insert_with_tags(end_iter, special_text, *all_tags)
if 'url' in tags:
puny_text = puny_encode(special_text).decode('utf-8')
if not puny_text.endswith('-'):
puny_text = helpers.puny_encode_url(special_text)
if puny_text != special_text:
puny_tags = []
if use_other_tags:
puny_tags += other_tags
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment