diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-08-08 00:00:05 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-08-08 00:01:07 +0200 |
commit | 0a0c1675675498d2a384001c3d007fca2c6329cd (patch) | |
tree | af15bf12709d5b149468fa0bc87c38e85061a36d | |
parent | 02992dd1e73f925be5720f9af0d2ee2b43c3ed99 (diff) | |
download | exchange-0a0c1675675498d2a384001c3d007fca2c6329cd.tar.gz exchange-0a0c1675675498d2a384001c3d007fca2c6329cd.zip |
-require receiver-name in iban payto URIs
-rw-r--r-- | src/json/test_json_wire.c | 2 | ||||
-rw-r--r-- | src/util/payto.c | 42 |
2 files changed, 35 insertions, 9 deletions
diff --git a/src/json/test_json_wire.c b/src/json/test_json_wire.c index f9264c61c..b417b25fe 100644 --- a/src/json/test_json_wire.c +++ b/src/json/test_json_wire.c | |||
@@ -34,7 +34,7 @@ main (int argc, | |||
34 | json_t *wire_iban; | 34 | json_t *wire_iban; |
35 | const char *payto_xtalerbank = "payto://x-taler-bank/42"; | 35 | const char *payto_xtalerbank = "payto://x-taler-bank/42"; |
36 | const char *payto_iban = | 36 | const char *payto_iban = |
37 | "payto://iban/BIC-TO-BE-SKIPPED/DE89370400440532013000"; | 37 | "payto://iban/BIC-TO-BE-SKIPPED/DE89370400440532013000?receiver-name=Test"; |
38 | char *p_xtalerbank; | 38 | char *p_xtalerbank; |
39 | char *p_iban; | 39 | char *p_iban; |
40 | 40 | ||
diff --git a/src/util/payto.c b/src/util/payto.c index 7819184e8..b8fd2e43a 100644 --- a/src/util/payto.c +++ b/src/util/payto.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of TALER | 2 | This file is part of TALER |
3 | Copyright (C) 2019-2020 Taler Systems SA | 3 | Copyright (C) 2019-2021 Taler Systems SA |
4 | 4 | ||
5 | TALER is free software; you can redistribute it and/or modify it under the | 5 | TALER is free software; you can redistribute it and/or modify it under the |
6 | terms of the GNU General Public License as published by the Free Software | 6 | terms of the GNU General Public License as published by the Free Software |
@@ -29,14 +29,16 @@ | |||
29 | 29 | ||
30 | 30 | ||
31 | /** | 31 | /** |
32 | * Extract the subject value from the URI parameters. | 32 | * Extract the value under @a key from the URI parameters. |
33 | * | 33 | * |
34 | * @param payto_uri the URL to parse | 34 | * @param payto_uri the URL to parse |
35 | * @return NULL if the subject parameter is not found. | 35 | * @param search_key key to look for, including "=" |
36 | * @return NULL if the @a key parameter is not found. | ||
36 | * The caller should free the returned value. | 37 | * The caller should free the returned value. |
37 | */ | 38 | */ |
38 | char * | 39 | static char * |
39 | TALER_payto_get_subject (const char *payto_uri) | 40 | payto_get_key (const char *payto_uri, |
41 | const char *search_key) | ||
40 | { | 42 | { |
41 | const char *key; | 43 | const char *key; |
42 | const char *value_start; | 44 | const char *value_start; |
@@ -49,8 +51,8 @@ TALER_payto_get_subject (const char *payto_uri) | |||
49 | 51 | ||
50 | do { | 52 | do { |
51 | if (0 == strncasecmp (++key, | 53 | if (0 == strncasecmp (++key, |
52 | "subject", | 54 | search_key, |
53 | strlen ("subject"))) | 55 | strlen (search_key))) |
54 | { | 56 | { |
55 | value_start = strchr (key, | 57 | value_start = strchr (key, |
56 | (unsigned char) '='); | 58 | (unsigned char) '='); |
@@ -69,6 +71,21 @@ TALER_payto_get_subject (const char *payto_uri) | |||
69 | 71 | ||
70 | 72 | ||
71 | /** | 73 | /** |
74 | * Extract the subject value from the URI parameters. | ||
75 | * | ||
76 | * @param payto_uri the URL to parse | ||
77 | * @return NULL if the subject parameter is not found. | ||
78 | * The caller should free the returned value. | ||
79 | */ | ||
80 | char * | ||
81 | TALER_payto_get_subject (const char *payto_uri) | ||
82 | { | ||
83 | return payto_get_key (payto_uri, | ||
84 | "subject="); | ||
85 | } | ||
86 | |||
87 | |||
88 | /** | ||
72 | * Obtain the payment method from a @a payto_uri. The | 89 | * Obtain the payment method from a @a payto_uri. The |
73 | * format of a payto URI is 'payto://$METHOD/$SOMETHING'. | 90 | * format of a payto URI is 'payto://$METHOD/$SOMETHING'. |
74 | * We return $METHOD. | 91 | * We return $METHOD. |
@@ -432,7 +449,7 @@ validate_iban (const char *iban) | |||
432 | * Validate payto://iban/ account URL (only account information, | 449 | * Validate payto://iban/ account URL (only account information, |
433 | * wire subject and amount are ignored). | 450 | * wire subject and amount are ignored). |
434 | * | 451 | * |
435 | * @param account_url URL to parse | 452 | * @param account_url payto URL to parse |
436 | * @return NULL on success, otherwise an error message | 453 | * @return NULL on success, otherwise an error message |
437 | * to be freed by the caller | 454 | * to be freed by the caller |
438 | */ | 455 | */ |
@@ -470,6 +487,15 @@ validate_payto_iban (const char *account_url) | |||
470 | return err; | 487 | return err; |
471 | } | 488 | } |
472 | GNUNET_free (result); | 489 | GNUNET_free (result); |
490 | { | ||
491 | char *target; | ||
492 | |||
493 | target = payto_get_key (account_url, | ||
494 | "receiver-name="); | ||
495 | if (NULL == target) | ||
496 | return GNUNET_strdup ("'receiver-name' parameter missing"); | ||
497 | GNUNET_free (target); | ||
498 | } | ||
473 | return NULL; | 499 | return NULL; |
474 | } | 500 | } |
475 | 501 | ||