Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape new lines for TEXT->HTML conversions #617

Merged
merged 1 commit into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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