From def536da5aec8724a72ae50728abe33f6b89a4bd Mon Sep 17 00:00:00 2001 From: mjk Date: Sat, 12 Nov 2022 20:38:59 +0000 Subject: imprv: Restore ability to manually disambiguate JID-like addresses ...by storing them in `href` attributes as internal-use `about:ambiguous-address?a@b.c` URIs. Storing raw `a@b.c` in `href` wouldn't make a lot of semantic sense, as that's a relative-path URI with the meaning of "the thing named 'a@b.c' in the same directory as the current document". Plus, it would either entail handling these addresses outside `parse_uri()`, or changing its purpose of parsing only absolute URIs. --- test/no_gui/test_styling.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/no_gui/test_styling.py b/test/no_gui/test_styling.py index 6a4644d0f..1979e6fb6 100644 --- a/test/no_gui/test_styling.py +++ b/test/no_gui/test_styling.py @@ -15,7 +15,7 @@ from gajim.common.styling import EmphasisSpan from gajim.common.styling import StrikeSpan from gajim.common.styling import Hyperlink from gajim.common.styling import process_uris -from gajim.common.text_helpers import jid_to_iri +from gajim.common.text_helpers import escape_iri_query app.settings = MagicMock() @@ -313,6 +313,7 @@ URIS = [ 'file:///x:/foo/bar/baz', # windows 'file://localhost/foo/bar/baz', 'file://nonlocalhost/foo/bar/baz', + 'about:ambiguous-address?a@b.c', # These seem to be from https://mathiasbynens.be/demo/url-regex 'http://foo.com/blah_blah', @@ -437,6 +438,11 @@ UNACCEPTABLE_URIS = [ 'file:a/', 'file:a/b', + 'about:', + 'about:asdfasdf', + 'about:ambiguous-address', + 'about:ambiguous-address?', + 'mailtomailto:foo@bar.com.uk', ] @@ -539,12 +545,12 @@ class Test(unittest.TestCase): self.assertEqual([link.text for link in hlinks], [], text) def test_jids(self): - for jid in JIDS: - text = self.wrap(jid) - uri = jid_to_iri(jid) + for jidlike in JIDS: + text = self.wrap(jidlike) + uri = 'about:ambiguous-address?' + escape_iri_query(jidlike) hlinks = process_uris(text) self.assertEqual([(link.text, link.uri) for link in hlinks], - [(jid, uri)], text) + [(jidlike, uri)], text) def test_nonjids(self): for foo in NONJIDS: -- cgit v1.2.3