Treat RIDs with non-base58 characters as invalid

parseRepositoryId threw instead of returning undefined, so the seed form
crashed on a typo instead of saying the RID is invalid.
This commit is contained in:
Rūdolfs Ošiņš
2026-10-01 18:20:24 +02:00
parent 4a3cdd9849
commit 17e7a29cb9
2 changed files with 17 additions and 7 deletions
+6 -1
View File
@@ -47,7 +47,12 @@ export function parseRepositoryId(
): { prefix: string; pubkey: string } | undefined {
const match = /^(rad:)?(z[a-zA-Z0-9]+)$/.exec(rid);
if (match) {
const hex = bs58.decode(match[2].substring(1));
let hex: Uint8Array;
try {
hex = bs58.decode(match[2].substring(1));
} catch {
return undefined;
}
if (hex.byteLength !== 20) {
return undefined;
}