From d6074c13863fd283ab71cacecd6fd4b8b0478838 Mon Sep 17 00:00:00 2001 From: selberhad Date: Fri, 7 Oct 2022 22:19:58 -0400 Subject: [PATCH] change protocol-relative urls to http --- evennia/utils/tests/test_tagparsing.py | 10 +++++----- evennia/utils/text2html.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/evennia/utils/tests/test_tagparsing.py b/evennia/utils/tests/test_tagparsing.py index 933d38d3f2..76cc9dd801 100644 --- a/evennia/utils/tests/test_tagparsing.py +++ b/evennia/utils/tests/test_tagparsing.py @@ -250,13 +250,13 @@ class TestTextToHTMLparser(TestCase): def test_url_scheme_ftp(self): self.assertEqual( self.parser.convert_urls("ftp.example.com"), - 'ftp.example.com', + 'ftp.example.com', ) def test_url_scheme_www(self): self.assertEqual( self.parser.convert_urls("www.example.com"), - 'www.example.com', + 'www.example.com', ) def test_url_scheme_ftpproto(self): @@ -280,7 +280,7 @@ class TestTextToHTMLparser(TestCase): def test_url_chars_slash(self): self.assertEqual( self.parser.convert_urls("www.example.com/homedir"), - 'www.example.com/homedir', + 'www.example.com/homedir', ) def test_url_chars_colon(self): @@ -316,13 +316,13 @@ class TestTextToHTMLparser(TestCase): def test_url_edge_following_period_eol(self): self.assertEqual( self.parser.convert_urls("www.example.com."), - 'www.example.com.', + 'www.example.com.', ) def test_url_edge_following_period(self): self.assertEqual( self.parser.convert_urls("see www.example.com. "), - 'see www.example.com. ', + 'see www.example.com. ', ) def test_url_edge_brackets(self): diff --git a/evennia/utils/text2html.py b/evennia/utils/text2html.py index d10c1c5d39..9ea74bf269 100644 --- a/evennia/utils/text2html.py +++ b/evennia/utils/text2html.py @@ -154,11 +154,11 @@ class TextToHTMLparser(object): href = m.group(1) label = href # if there is no protocol (i.e. starts with www or ftp) - # prefix with // so the link isn't treated as relative + # prefix with http:// so the link isn't treated as relative if not self.re_protocol.match(href): if not self.re_valid_no_protocol.match(href): return text - href = "//" + href + href = "http://" + href rest = m.group(2) # -> added target to output prevent the web browser from attempting to # change pages (and losing our webclient session).