From 3f3bbb75299a780583046d8775be314bf72f70ff Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Thu, 23 Mar 2023 08:09:49 -0300 Subject: [PATCH] ensure nip05 results are valid keys or nil. --- nip05/nip05.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nip05/nip05.go b/nip05/nip05.go index e5cff9c..2f97340 100644 --- a/nip05/nip05.go +++ b/nip05/nip05.go @@ -1,6 +1,7 @@ package nip05 import ( + "encoding/hex" "encoding/json" "fmt" "net/http" @@ -52,7 +53,17 @@ func QueryIdentifier(fullname string) *nostr.ProfilePointer { return nil } - pubkey, _ := result.Names[name] + pubkey, ok := result.Names[name] + if !ok { + return nil + } + + if len(pubkey) == 64 { + if _, err := hex.DecodeString(pubkey); err != nil { + return nil + } + } + relays, _ := result.Relays[pubkey] return &nostr.ProfilePointer{