ensure nip05 results are valid keys or nil.

This commit is contained in:
fiatjaf 2023-03-23 08:09:49 -03:00
parent 4b1f69ec27
commit 3f3bbb7529
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1

View File

@ -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{