Skip to content

Commit

Permalink
Fixed Bad Attachment Web/API Error; refs #168
Browse files Browse the repository at this point in the history
  • Loading branch information
caronc committed Feb 1, 2024
1 parent d556f14 commit ecc8655
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions apprise_api/api/tests/test_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ def test(*args, **kwargs):
with self.assertRaises(ValueError):
parse_attachments(attachment_payload, {})

# We allow empty entries, this is okay; there is just nothing
# returned at the end of the day
assert parse_attachments({''}, {}) == []

# We can't parse entries that are not base64 but specified as
# though they are
attachment_payload = {
Expand Down
9 changes: 8 additions & 1 deletion apprise_api/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ def __init__(self, filename, delete=True, **kwargs):
'Could not prepare {} attachment in {}'.format(
filename, settings.APPRISE_ATTACH_DIR))


# Prepare our item
super().__init__(name=filename, **kwargs)

Expand Down Expand Up @@ -272,6 +271,14 @@ def parse_attachments(attachment_payload, files_request):
# Prepare our Attachment
#
if isinstance(entry, str):
if not entry.strip():
# ignore blank entries; these can come from using the
# api/website and submitting without an element defined.
# There is no need have a bad outcome; just decrement our
# counter and move along
count -= 1
continue

if not re.match(r'^https?://.+', entry[:10], re.I):
# We failed to retrieve the product
raise ValueError(
Expand Down

0 comments on commit ecc8655

Please sign in to comment.