allow non-hex e and p tags

mostly because some clients use p tags in follow lists for whatever reason. follow lists are generally fetched by pubkey+kind so the missing index because it's not a pubkey is really nbd, and pubkey tag searches will also work with the kind.
This commit is contained in:
2025-06-10 22:10:33 +01:00
parent faf3ebfdba
commit 789c7913e7
6 changed files with 37 additions and 19 deletions

View File

@@ -63,7 +63,7 @@ func (d *D) GetWordsFromContent(ev *event.E) (wordMap map[string]int) {
!IsEntity(w) &&
!bytes.Contains(w, []byte(".")) {
if len(w) == 64 || len(w) == 128 {
if _, err := hex.Dec(string(w)); !chk.E(err) {
if _, err := hex.Dec(string(w)); err == nil {
continue
}
}

View File

@@ -164,6 +164,9 @@ func (d *D) GetEventIndexes(ev *event.E) (indices [][]byte, ser *varint.V, err e
continue
}
ph := pubhash.New()
if len(pkb) == 0 {
continue
}
if err = ph.FromPubkey(pkb); chk.E(err) {
err = nil
continue

View File

@@ -88,7 +88,7 @@ func TestGetEventIndexes(t *testing.T) {
// check the event encodes to binary, decodes, and produces the identical canonical form
binE := new(bytes.Buffer)
if err = ev.MarshalWrite(binE); chk.E(err) {
// log.I.F("bogus tags probably: %s", b)
log.I.F("bogus tags probably: %s", b)
encErrs++
// events that marshal with errors have e and p tag values that aren't hex and should not be accepted
continue

View File

@@ -50,7 +50,7 @@ func TestD_StoreEvent(t *testing.T) {
count++
if count%1000 == 0 {
log.I.F("unmarshaled %d events", count)
break
// break
}
if err = d.StoreEvent(ev); chk.E(err) {
continue