Escape new lines for TEXT->HTML conversions (#617)

This commit is contained in:
Chris Caron 2022-07-01 09:31:06 -04:00 committed by GitHub
parent 1519e98cda
commit e95484349e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 3 deletions

View File

@ -359,7 +359,7 @@ class URLBase(object):
.replace(u' ', u' ')
if convert_new_lines:
return escaped.replace(u'\n', u'<br/>')
return escaped.replace(u'\n', u'<br/>')
return escaped

View File

@ -70,7 +70,8 @@ def text_to_html(content):
Converts specified content from plain text to HTML.
"""
return URLBase.escape_html(content)
# First eliminate any carriage returns
return URLBase.escape_html(content, convert_new_lines=True)
def html_to_text(content):

View File

@ -183,7 +183,7 @@ def test_notify_base():
assert NotifyBase.escape_html(
"<content>'\t \n</content>", convert_new_lines=True) == \
'&lt;content&gt;&apos;&emsp;&nbsp;&lt;br/&gt;&lt;/content&gt;'
'&lt;content&gt;&apos;&emsp;&nbsp;<br/>&lt;/content&gt;'
# Test invalid data
assert NotifyBase.split_path(None) == []