commit 287de663c448d082b8f3af217d32b2e9f8c23ddb
parent 45fbbf276dce47c8d0b309053bd2513a2cd1665f
Author: Florian Dold <florian@dold.me>
Date: Wed, 22 Jul 2026 18:28:34 +0200
taler:// URI parsing must alway be case insensitive in first components
Diffstat:
2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/packages/taler-util/src/taleruri.test.ts b/packages/taler-util/src/taleruri.test.ts
@@ -747,6 +747,23 @@ import { AmountString } from "./types-taler-common.js";
const r2 = TalerUris.parse(url2);
assert.ok(Result.isError(r2));
});
+
+ test("upper-cased TALER:// URIs", (t) => {
+ // We must also accept upper-case URIs,
+ // where the first three components are treated
+ // case-insensitively.
+ const uri1 = "TALER://PAY/MY.TALER-OPS.CH/instances/foo/TeSt123/#snack";
+ const r1 = TalerUris.parse(uri1);
+ assert.ok(Result.isOk(r1));
+ const p = r1.value;
+ assert(p.type == TalerUriAction.Pay);
+ assert.deepEqual(
+ p.merchantBaseUrl,
+ "https://my.taler-ops.ch/instances/foo/",
+ );
+ // Not case sensitive
+ assert.deepEqual(p.orderId, "TeSt123");
+ });
}
test("parseAddContact keeps the mailbox sub-path", () => {
diff --git a/packages/taler-util/src/taleruri.ts b/packages/taler-util/src/taleruri.ts
@@ -346,12 +346,6 @@ export namespace TalerUris {
* do not check path component format
*/
ignoreComponentError?: boolean;
- /**
- * tolerate upper-case on taler:// and
- * target action.
- * Userful for user input
- */
- ignoreUppercase?: boolean;
}
export type InvalidTargetPathDetail =
@@ -426,10 +420,10 @@ export namespace TalerUris {
export function parse(s: string, opts: PaytoParseOptions = {}): ParseResult {
// check prefix
let isHttp = false;
- const prefixCheck = opts.ignoreUppercase ? s.toLowerCase() : s;
+ const prefixCheckStr = s.toLowerCase();
if (
- !prefixCheck.startsWith(TALER_PREFIX) &&
- !(isHttp = prefixCheck.startsWith(TALER_HTTP_PREFIX))
+ !prefixCheckStr.startsWith(TALER_PREFIX) &&
+ !(isHttp = prefixCheckStr.startsWith(TALER_HTTP_PREFIX))
) {
return Result.error(TalerUriParseError.WRONG_PREFIX);
}
@@ -448,9 +442,7 @@ export namespace TalerUris {
firstSlashPos === -1 ? path : path.slice(0, firstSlashPos)
) as TalerUriAction;
- const uriType = opts.ignoreUppercase
- ? (uriTypeUncased.toLowerCase() as TalerUriAction)
- : uriTypeUncased;
+ const uriType = uriTypeUncased.toLowerCase() as TalerUriAction;
if (!Object.prototype.hasOwnProperty.call(supportedTargets, uriType)) {
return Result.errorWithDetail(TalerUriParseError.UNSUPPORTED, {