diff --git a/apprise/plugins/NotifyDiscord.py b/apprise/plugins/NotifyDiscord.py index a1bb0720..83b6ea97 100644 --- a/apprise/plugins/NotifyDiscord.py +++ b/apprise/plugins/NotifyDiscord.py @@ -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[^\n]+)(\n|\s*$)' diff --git a/test/test_plugin_discord.py b/test/test_plugin_discord.py index 76d2988a..937b300d 100644 --- a/test/test_plugin_discord.py +++ b/test/test_plugin_discord.py @@ -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): """