nostr-rs-relay icon indicating copy to clipboard operation
nostr-rs-relay copied to clipboard

NIP-33 Bug on querying identifier tag (postgresql)

Open mstoecklein opened this issue 1 year ago • 2 comments

I was querying a specific replaceable parametrized event that contains a #d tag with an identifier that contains an even amount of characters. This caused the hex code check to be completely ignored and assumed to be a hex code.

Here is the code that causes the error: https://github.com/scsibug/nostr-rs-relay/blob/4adad4c3a99c1454952e46478d42c838e2730e6f/src/repo/postgres.rs#L889

This seems to fix it:

if v.len() % 2 == 0 && is_lower_hex(v) {
    tag_query.push_bind(hex::decode(v).ok());
} else {
    tag_query.push_bind(v.as_bytes());
}

I don't know much about Rust, which is why I didn't do a PR.

mstoecklein avatar Jul 18 '23 21:07 mstoecklein

It should be fixed by https://github.com/scsibug/nostr-rs-relay/pull/164

v0l avatar Nov 20 '23 10:11 v0l

I will test it during the week. Thank you.

mstoecklein avatar Nov 22 '23 11:11 mstoecklein