nip19: length 0 on TLV is not forbidden.

This commit is contained in:
fiatjaf
2023-12-23 19:28:13 -03:00
parent 5d6c2b9e5d
commit 566437fe2e
2 changed files with 19 additions and 1 deletions

View File

@@ -149,7 +149,6 @@ function parseTLV(data: Uint8Array): TLV {
while (rest.length > 0) {
let t = rest[0]
let l = rest[1]
if (!l) throw new Error(`malformed TLV ${t}`)
let v = rest.slice(2, 2 + l)
rest = rest.slice(2 + l)
if (v.length < l) throw new Error(`not enough data to read on TLV ${t}`)