[Fix html links
Adrian Georgescu **20261016214203
Ignore-this: 5031ab42ef487cee7caed4eda24638c36888492f77c9c78148180b3eb82315f16bab9f8a5c004e8
] hunk ./blink/messagepane/format.py 117
+ return _link_addresses(text).replace('\r\n', '\n').replace('\n', '
')
+
+
+def _link_addresses(text):
+ """Escaped text with web and mail addresses as links; whitespace left as it is."""
hunk ./blink/messagepane/format.py 139
- return ''.join(parts).replace('\r\n', '\n').replace('\n', '
')
+ return ''.join(parts)
hunk ./blink/messagepane/format.py 190
- if not self.skip:
+ if self.skip:
+ return
+ if 'a' in self.open: # already inside a link the peer made
hunk ./blink/messagepane/format.py 194
+ else: # a bare address pasted as text (e.g. a span from a browser copy)
+ self.out.append(_link_addresses(data))
hunk ./tests/test_messagepane_format.py 67
+ def test_sanitize_links_bare_addresses(self):
+ self.assertEqual(fmt.sanitize_html('https://x.com/a?s=20'),
+ 'https://x.com/a?s=20')
+ self.assertEqual(fmt.sanitize_html('https://a.b'), 'https://a.b')
+