Discord bugfix to better handle provided markdown (#718)

This commit is contained in:
Chris Caron 2022-10-25 19:33:12 -04:00 committed by GitHub
parent b3cca772f6
commit 17202e2fa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 1 deletions

View File

@ -580,7 +580,7 @@ class NotifyDiscord(NotifyBase):
if description:
# Strip description from our string since it has been handled
# now.
markdown = re.sub(description, '', markdown, count=1)
markdown = re.sub(re.escape(description), '', markdown, count=1)
regex = re.compile(
r'\s*#[# \t\v]*(?P<name>[^\n]+)(\n|\s*$)'

View File

@ -362,6 +362,43 @@ def test_plugin_discord_general(mock_post):
body='body', title='title', notify_type=NotifyType.INFO) is True
@mock.patch('requests.post')
def test_plugin_discord_markdown_extra(mock_post):
"""
NotifyDiscord() Markdown Extra Checks
"""
# Initialize some generic (but valid) tokens
webhook_id = 'A' * 24
webhook_token = 'B' * 64
# Prepare Mock
mock_post.return_value = requests.Request()
mock_post.return_value.status_code = requests.codes.ok
# Reset our apprise object
a = Apprise()
# We want to further test our markdown support to accomodate bug rased on
# 2022.10.25; see https://github.com/caronc/apprise/issues/717
assert a.add(
'discord://{webhook_id}/{webhook_token}/'
'?format=markdown&footer=Yes'.format(
webhook_id=webhook_id,
webhook_token=webhook_token)) is True
test_markdown = "[green-blue](https://google.com)"
# This call includes an image with it's payload:
assert a.notify(body=test_markdown, title='title',
notify_type=NotifyType.INFO,
body_format=NotifyFormat.TEXT) is True
assert a.notify(
body='body', title='title', notify_type=NotifyType.INFO) is True
@mock.patch('requests.post')
def test_plugin_discord_attachments(mock_post):
"""