use new parsing API, fixes issues
This commit is contained in:
parent
bf3c7dd10f
commit
087de13e0a
@ -70,6 +70,8 @@ TALER_BANK_setup_auth_ (CURL *easy,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain the URL to use for an API request.
|
* Obtain the URL to use for an API request.
|
||||||
|
* FIXME: duplicates MAH_path_to_url2, and likely also logic in util!
|
||||||
|
* FIXME: duplicates TEAH_path_to_url2, and likely also logic in util!
|
||||||
*
|
*
|
||||||
* @param u base URL of the bank.
|
* @param u base URL of the bank.
|
||||||
* @param path Taler API path (i.e. "/history").
|
* @param path Taler API path (i.e. "/history").
|
||||||
|
@ -399,75 +399,32 @@ parse_payto_iban (const char *account_url,
|
|||||||
* Parse payto://x-taler-bank/ account URL (only account information,
|
* Parse payto://x-taler-bank/ account URL (only account information,
|
||||||
* wire subject and amount are ignored).
|
* wire subject and amount are ignored).
|
||||||
*
|
*
|
||||||
* @param account_url URL to parse
|
* @param payto_url URL to parse
|
||||||
* @param account[out] set to information, can be NULL
|
* @param account[out] set to information, can be NULL
|
||||||
* @return #TALER_EC_NONE if @a account_url is well-formed
|
* @return #TALER_EC_NONE if @a account_url is well-formed
|
||||||
*/
|
*/
|
||||||
static enum TALER_ErrorCode
|
static enum TALER_ErrorCode
|
||||||
parse_payto_x_taler_bank (const char *account_url,
|
parse_payto_x_taler_bank (const char *payto_url,
|
||||||
struct TALER_Account *r_account)
|
struct TALER_Account *r_account)
|
||||||
{
|
{
|
||||||
const char *hostname;
|
|
||||||
const char *account;
|
|
||||||
const char *q;
|
|
||||||
unsigned int port;
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
#define PREFIX "payto://x-taler-bank/"
|
#define PREFIX "payto://x-taler-bank/"
|
||||||
if (0 != strncasecmp (account_url,
|
if (0 != strncasecmp (payto_url,
|
||||||
PREFIX,
|
PREFIX,
|
||||||
strlen (PREFIX)))
|
strlen (PREFIX)))
|
||||||
return TALER_EC_PAYTO_WRONG_METHOD;
|
return TALER_EC_PAYTO_WRONG_METHOD;
|
||||||
hostname = &account_url[strlen (PREFIX)];
|
#undef PREFIX
|
||||||
if (NULL == (account = strchr (hostname,
|
|
||||||
(unsigned char) '/')))
|
|
||||||
return TALER_EC_PAYTO_MALFORMED;
|
|
||||||
account++;
|
|
||||||
if (NULL == r_account)
|
|
||||||
return TALER_EC_NONE;
|
|
||||||
q = strchr (account,
|
|
||||||
(unsigned char) '?');
|
|
||||||
if (0 == q)
|
|
||||||
q = account + strlen (account);
|
|
||||||
r_account->details.x_taler_bank.hostname
|
r_account->details.x_taler_bank.hostname
|
||||||
= GNUNET_strndup (hostname,
|
= TALER_xtalerbank_base_url_from_payto (payto_url);
|
||||||
account - hostname);
|
if (NULL == r_account->details.x_taler_bank.hostname)
|
||||||
port = 443; /* if non given, equals 443. */
|
return TALER_EC_PAYTO_MALFORMED;
|
||||||
if (NULL != (p = strchr (r_account->details.x_taler_bank.hostname,
|
r_account->details.x_taler_bank.account_base_url
|
||||||
(unsigned char) ':')))
|
= TALER_xtalerbank_account_url_from_payto (payto_url);
|
||||||
|
if (NULL == r_account->details.x_taler_bank.hostname)
|
||||||
{
|
{
|
||||||
p++;
|
|
||||||
if (1 != sscanf (p,
|
|
||||||
"%u",
|
|
||||||
&port))
|
|
||||||
{
|
|
||||||
GNUNET_break (0);
|
|
||||||
TALER_LOG_ERROR ("Malformed host from payto:// URI\n");
|
|
||||||
GNUNET_free (r_account->details.x_taler_bank.hostname);
|
GNUNET_free (r_account->details.x_taler_bank.hostname);
|
||||||
r_account->details.x_taler_bank.hostname = NULL;
|
r_account->details.x_taler_bank.hostname = NULL;
|
||||||
return TALER_EC_PAYTO_MALFORMED;
|
return TALER_EC_PAYTO_MALFORMED;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (443 != port)
|
|
||||||
{
|
|
||||||
GNUNET_assert
|
|
||||||
(GNUNET_SYSERR != GNUNET_asprintf
|
|
||||||
(&r_account->details.x_taler_bank.account_base_url,
|
|
||||||
"http://%s/%.*s",
|
|
||||||
r_account->details.x_taler_bank.hostname,
|
|
||||||
(int) (q - account),
|
|
||||||
account));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GNUNET_assert
|
|
||||||
(GNUNET_SYSERR != GNUNET_asprintf
|
|
||||||
(&r_account->details.x_taler_bank.account_base_url,
|
|
||||||
"https://%s/%.*s",
|
|
||||||
r_account->details.x_taler_bank.hostname,
|
|
||||||
(int) (q - account),
|
|
||||||
account));
|
|
||||||
}
|
|
||||||
r_account->type = TALER_PAC_X_TALER_BANK;
|
r_account->type = TALER_PAC_X_TALER_BANK;
|
||||||
return TALER_EC_NONE;
|
return TALER_EC_NONE;
|
||||||
}
|
}
|
||||||
|
@ -1422,6 +1422,7 @@ TEAH_path_to_url (struct TALER_EXCHANGE_Handle *h,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain the URL to use for an API request.
|
* Obtain the URL to use for an API request.
|
||||||
|
* FIXME: duplicates MAH_path_to_url2, and likely also logic in util!
|
||||||
*
|
*
|
||||||
* @param base_url base URL of the exchange (i.e. "http://exchange/")
|
* @param base_url base URL of the exchange (i.e. "http://exchange/")
|
||||||
* @param path Taler API path (i.e. "/reserve/withdraw")
|
* @param path Taler API path (i.e. "/reserve/withdraw")
|
||||||
|
@ -121,14 +121,11 @@ run (void *cls,
|
|||||||
*/
|
*/
|
||||||
CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1",
|
CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1",
|
||||||
"EUR:5.01"),
|
"EUR:5.01"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a reserve exist, according to the previous
|
* Make a reserve exist, according to the previous
|
||||||
* transfer.
|
* transfer.
|
||||||
*/
|
*/
|
||||||
CMD_EXEC_WIREWATCH ("wirewatch-1"),
|
CMD_EXEC_WIREWATCH ("wirewatch-1"),
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Withdraw EUR:5.
|
* Withdraw EUR:5.
|
||||||
*/
|
*/
|
||||||
@ -136,7 +133,6 @@ run (void *cls,
|
|||||||
"create-reserve-1",
|
"create-reserve-1",
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the reserve is depleted.
|
* Check the reserve is depleted.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user