commit 71e938bd96d0d0a8b1954a48cb1bd9e7d93a1e56
parent f6dfe4ce296e0cee3fa2f319eedbd695f6fc2320
Author: Florian Dold <dold@taler.net>
Date: Tue, 21 Jul 2026 10:52:38 +0200
util: match the payto scheme and target type case-insensitively
The C compares the prefix with strncasecmp and the method with strcasecmp,
so payto://IBAN/... is a URI the exchange accepts; parsing it here failed
with WRONG_PREFIX or UNSUPPORTED.
Diffstat:
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/packages/taler-util/src/payto.ts b/packages/taler-util/src/payto.ts
@@ -613,7 +613,9 @@ export namespace Paytos {
| ResultError<PaytoParseError.COMPONENTS_LENGTH, { targetType: PaytoType }>
| ResultError<PaytoParseError.INVALID_TARGET_PATH, TargetPathErrorDetail>
| ResultError<PaytoParseError.INCOMPLETE, { targetType: string }> {
- if (!s.startsWith(PAYTO_PREFIX)) {
+ // The scheme and the target type are case insensitive, as in the C
+ // reference (strncasecmp on the prefix, strcasecmp on the method).
+ if (s.slice(0, PAYTO_PREFIX.length).toLowerCase() !== PAYTO_PREFIX) {
return Result.error(PaytoParseError.WRONG_PREFIX);
}
@@ -625,9 +627,9 @@ export namespace Paytos {
const firstSlashPos = acct.indexOf("/");
- const targetType = (
- firstSlashPos === -1 ? acct : acct.slice(0, firstSlashPos)
- ) as PaytoType;
+ const rawTargetType =
+ firstSlashPos === -1 ? acct : acct.slice(0, firstSlashPos);
+ const targetType = rawTargetType.toLowerCase() as PaytoType;
if (
!opts.allowUnsupported &&
!Object.prototype.hasOwnProperty.call(supportedTargets, targetType)
@@ -862,7 +864,7 @@ export namespace Paytos {
default: {
if (opts.allowUnsupported) {
return Result.of<URI>(
- createUnsupported(targetType, targetPath, params),
+ createUnsupported(rawTargetType, targetPath, params),
);
}
assertUnreachable(targetType);