misc: linkify emails (#78211) #770

Merged
fpeters merged 1 commits from wip/78211-linkify-emails into main 2023-10-27 08:35:05 +02:00
2 changed files with 6 additions and 1 deletions

View File

@ -480,6 +480,11 @@ def test_wysiwygwidget():
assert not widget.has_error()
assert widget.parse() == '<a>a</a>' # javascript: got filtered
widget = WysiwygTextWidget('test')
mock_form_submission(req, widget, {'test': 'an email address: test@example.net'})
assert not widget.has_error()
assert widget.parse() == 'an email address: <a href="mailto:test@example.net">test@example.net</a>'
# check comments are kept
widget = WysiwygTextWidget('test')
mock_form_submission(req, widget, {'test': '<p>hello</p><!-- world --><p>.</p>'})

View File

@ -2552,7 +2552,7 @@ class WysiwygTextWidget(TextWidget):
styles=self.ALL_STYLES,
strip=True,
strip_comments=False,
filters=[partial(LinkifyFilter, skip_tags=['pre'], parse_email=False)],
filters=[partial(LinkifyFilter, skip_tags=['pre'], parse_email=True)],
)
self.value = cleaner.clean(self.value)
if self.value.startswith('<br />'):