commit 571e6940d0374332b3ba7d7ecb93c029ce499589
parent 77c374a395800a1b98cbc6d30bcb4493422f8098
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 7 Dec 2025 15:57:14 +0100
adjust File dumping logic to latest spec
Diffstat:
1 file changed, 45 insertions(+), 1 deletion(-)
diff --git a/src/exchange/taler-exchange-httpd_aml-attributes-get.c b/src/exchange/taler-exchange-httpd_aml-attributes-get.c
@@ -251,8 +251,52 @@ dump_attachments (struct ResponseContext *rc,
json_object_foreach ((json_t *) attrs, k, e)
{
if (0 == strcmp (k,
- "FILE"))
+ "CONTENTS"))
{
+ const char *v;
+
+ /* Make sure this is the supported encoding */
+ v = json_string_value (json_object_get (attrs,
+ "ENCODING"));
+ if (NULL == v)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "`CONTENTS' attribute found without `ENCODING', skipping dumping attachment\n");
+ continue; /* maybe not a file!? */
+ }
+ if (0 != strcmp (v,
+ "base64"))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Attachment with unsupported encoding `%s' encountered, skipping attachment in PDF generation\n",
+ v);
+ continue;
+ }
+ v = json_string_value (json_object_get (attrs,
+ "MIME_TYPE"));
+ if (NULL == v)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "`CONTENTS' attribute found without `MIME_TYPE', skipping dumping attachment\n");
+ continue;
+ }
+ if (0 != strcmp (v,
+ "application/pdf"))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Attachment with unsupported mime type `%s' encountered, skipping attachment in PDF generation\n",
+ v);
+ continue;
+ }
+ /* Filename is optional, only log it */
+ v = json_string_value (json_object_get (attrs,
+ "FILENAME"));
+ if (NULL != v)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Dumping attachment `%s'\n",
+ v);
+ }
if (! dump_attachment (rc,
e))
ret = false;