mirror of
https://github.com/caronc/apprise-api.git
synced 2025-08-18 18:38:10 +02:00
Fixed Bad Attachment Web/API Error; refs #168
This commit is contained in:
@@ -283,6 +283,10 @@ class AttachmentTests(SimpleTestCase):
|
|||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
parse_attachments(attachment_payload, {})
|
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
|
# We can't parse entries that are not base64 but specified as
|
||||||
# though they are
|
# though they are
|
||||||
attachment_payload = {
|
attachment_payload = {
|
||||||
|
@@ -178,7 +178,6 @@ class HTTPAttachment(A_MGR['http']):
|
|||||||
'Could not prepare {} attachment in {}'.format(
|
'Could not prepare {} attachment in {}'.format(
|
||||||
filename, settings.APPRISE_ATTACH_DIR))
|
filename, settings.APPRISE_ATTACH_DIR))
|
||||||
|
|
||||||
|
|
||||||
# Prepare our item
|
# Prepare our item
|
||||||
super().__init__(name=filename, **kwargs)
|
super().__init__(name=filename, **kwargs)
|
||||||
|
|
||||||
@@ -272,6 +271,14 @@ def parse_attachments(attachment_payload, files_request):
|
|||||||
# Prepare our Attachment
|
# Prepare our Attachment
|
||||||
#
|
#
|
||||||
if isinstance(entry, str):
|
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):
|
if not re.match(r'^https?://.+', entry[:10], re.I):
|
||||||
# We failed to retrieve the product
|
# We failed to retrieve the product
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
Reference in New Issue
Block a user