From 0755ec6ac49ce5b728e7e1ed0f2d76c7d3e0718f Mon Sep 17 00:00:00 2001 From: Proudmuslim Date: Mon, 27 Nov 2023 19:13:09 -0800 Subject: [PATCH] nostr: filter out `GenericTagValue` variants that do not adhere to the spec --- crates/nostr/src/message/subscription.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/nostr/src/message/subscription.rs b/crates/nostr/src/message/subscription.rs index 0e73298ee..355032d11 100644 --- a/crates/nostr/src/message/subscription.rs +++ b/crates/nostr/src/message/subscription.rs @@ -737,7 +737,14 @@ where if let (Some('#'), Some(ch), None) = (chars.next(), chars.next(), chars.next()) { let tag: Alphabet = Alphabet::from_str(ch.to_string().as_str()) .map_err(serde::de::Error::custom)?; - let values = map.next_value()?; + let mut values: AllocSet = map.next_value()?; + + match tag { + Alphabet::P => values.retain(|v| matches!(v, GenericTagValue::Pubkey(_))), + Alphabet::E => values.retain(|v| matches!(v, GenericTagValue::EventId(_))), + _ => {} + } + generic_tags.insert(tag, values); } else { map.next_value::()?;