diff --git a/src.ts/hash/namehash.ts b/src.ts/hash/namehash.ts index e3916ec622..c06202e40a 100644 --- a/src.ts/hash/namehash.ts +++ b/src.ts/hash/namehash.ts @@ -44,6 +44,7 @@ function ensNameSplit(name: string): Array { */ export function ensNormalize(name: string): string { try { + if (name.length === 0) { throw new Error("empty label"); } return ens_normalize(name); } catch (error: any) { assertArgument(false, `invalid ENS name (${ error.message })`, "name", name); @@ -66,6 +67,8 @@ export function isValidName(name: string): name is string { export function namehash(name: string): string { assertArgument(typeof(name) === "string", "invalid ENS name; not a string", "name", name); + assertArgument(name.length, `invalid ENS name (empty label)`, "name", name); + let result: string | Uint8Array = Zeros; const comps = ensNameSplit(name); diff --git a/testcases/namehash.json.gz b/testcases/namehash.json.gz index 56af6b3d9a..be18676d69 100644 Binary files a/testcases/namehash.json.gz and b/testcases/namehash.json.gz differ