Skip to content

Commit

Permalink
Escape new lines for text->html conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
caronc committed Jul 1, 2022
1 parent 1519e98 commit 79f0db3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apprise/URLBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def escape_html(html, convert_new_lines=False, whitespace=True):
.replace(u' ', u' ')

if convert_new_lines:
return escaped.replace(u'\n', u'<br/>')
return escaped.replace(u'\n', u'<br/>')

return escaped

Expand Down
3 changes: 2 additions & 1 deletion apprise/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion test/test_notify_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) == []
Expand Down

0 comments on commit 79f0db3

Please sign in to comment.