fix(NIP-12): correctly search for mixed-case hex-like tags

Only lowercase and even-length tag values are stored as binary BLOBs.
Previously there was an error which search results from being returned
if the tag value was mixed-case and could be interpreted as hex.

A new database migration has been created to repair the `tag` table
for existing relays.

fixes: https://todo.sr.ht/~gheartsfield/nostr-rs-relay/37
This commit is contained in:
Greg Heartsfield
2022-08-17 16:34:11 -07:00
parent be8170342e
commit 035cf34673
6 changed files with 132 additions and 53 deletions
+3 -3
View File
@@ -57,7 +57,7 @@ where
}
/// Attempt to form a single-char tag name.
fn single_char_tagname(tagname: &str) -> Option<char> {
pub fn single_char_tagname(tagname: &str) -> Option<char> {
// We return the tag character if and only if the tagname consists
// of a single char.
let mut tagnamechars = tagname.chars();
@@ -301,7 +301,7 @@ mod tests {
fn empty_event_tag_match() -> Result<()> {
let event = simple_event();
assert!(!event
.generic_tag_val_intersect("e", &HashSet::from(["foo".to_owned(), "bar".to_owned()])));
.generic_tag_val_intersect('e', &HashSet::from(["foo".to_owned(), "bar".to_owned()])));
Ok(())
}
@@ -312,7 +312,7 @@ mod tests {
event.build_index();
assert_eq!(
event.generic_tag_val_intersect(
"e",
'e',
&HashSet::from(["foo".to_owned(), "bar".to_owned()])
),
true