diff options
author | Florian Dold <florian@dold.me> | 2020-12-02 12:39:44 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2020-12-02 12:42:35 +0100 |
commit | fd86a1a22a2dda6d3f741bf4fef3e220c5129ace (patch) | |
tree | 91bc0ac2eeb2a2eeeead5d742dbafc68316d532c /src/sync/sync-httpd_backup_post.c | |
parent | 065017d2f41716b38a9134ac210b69d55e654b1f (diff) | |
download | sync-fd86a1a22a2dda6d3f741bf4fef3e220c5129ace.tar.gz sync-fd86a1a22a2dda6d3f741bf4fef3e220c5129ace.tar.bz2 sync-fd86a1a22a2dda6d3f741bf4fef3e220c5129ace.zip |
use GNUNET_Buffer to generate URIs
This fixes an issue with URLs with double slashes being generated, which
would cause a merchant base URL mismatch error being detected by the
wallet.
(Example:
taler://pay/backend.int.taler.net/instances/Taler//2020.337-01M3QKVDPJEYE/)
Also, the comment about instances is removed, since instances don't need
any special support in sync, they are simply a different payment backend
base URL.
Diffstat (limited to 'src/sync/sync-httpd_backup_post.c')
-rw-r--r-- | src/sync/sync-httpd_backup_post.c | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/src/sync/sync-httpd_backup_post.c b/src/sync/sync-httpd_backup_post.c index 392675a..a254e30 100644 --- a/src/sync/sync-httpd_backup_post.c +++ b/src/sync/sync-httpd_backup_post.c @@ -235,6 +235,7 @@ make_payment_request (const char *order_id, char *hdr; char *pfx; char *hn; + struct GNUNET_Buffer hdr_buf = { 0 }; if (0 == strncasecmp ("https://", SH_backend_url, @@ -262,35 +263,19 @@ make_payment_request (const char *order_id, MHD_destroy_response (resp); return NULL; } - // FIXME: support instances? + + GNUNET_buffer_write_str (&hdr_buf, pfx); + GNUNET_buffer_write_str (&hdr_buf, "pay/"); + GNUNET_buffer_write_str (&hdr_buf, hn); + GNUNET_buffer_write_path (&hdr_buf, order_id); + /* No session ID */ + GNUNET_buffer_write_path (&hdr_buf, ""); if (NULL != token) { - char tok[256]; - - /* This path should not be taken, as we disabled tokens */ - GNUNET_assert (NULL != - GNUNET_STRINGS_data_to_string (token, - sizeof (*token), - tok, - sizeof (tok))); - GNUNET_asprintf (&hdr, - "%spay/%s%s%s/?c=%s", - pfx, - hn, - ('/' == hn[strlen (hn) - 1]) - ? "" - : "/", - order_id, - tok); - } - else - { - GNUNET_asprintf (&hdr, - "%spay/%s/%s/", - pfx, - hn, - order_id); + GNUNET_buffer_write_str (&hdr_buf, "?c="); + GNUNET_buffer_write_data_encoded (&hdr_buf, token, sizeof (*token)); } + hdr = GNUNET_buffer_reap_str (&hdr_buf); GNUNET_break (MHD_YES == MHD_add_response_header (resp, "Taler", |