Sanitize mentions on call
This commit is contained in:
Generated
+1
-1
@@ -1431,7 +1431,7 @@ checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "payphone"
|
name = "payphone"
|
||||||
version = "4.0.5"
|
version = "4.0.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"axum",
|
"axum",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "payphone"
|
name = "payphone"
|
||||||
version = "4.0.5"
|
version = "4.0.6"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
default-run = "payphone"
|
default-run = "payphone"
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,12 @@ pub trait SanitizeDiscordMarkdown {
|
|||||||
/// Returns:
|
/// Returns:
|
||||||
/// [`String`] - The sanitized string.
|
/// [`String`] - The sanitized string.
|
||||||
fn sanitize(&self, hard: bool) -> String;
|
fn sanitize(&self, hard: bool) -> String;
|
||||||
|
|
||||||
|
/// Sanitizes mentions in a string.
|
||||||
|
///
|
||||||
|
/// Returns:
|
||||||
|
/// [`String`] - The sanitized string.
|
||||||
|
fn sanitize_mentions(&self) -> String;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> SanitizeDiscordMarkdown for T
|
impl<T> SanitizeDiscordMarkdown for T
|
||||||
@@ -40,7 +46,13 @@ where
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Now block ping attempts — break mentions
|
// Now block ping attempts — break mentions
|
||||||
escaped
|
escaped.sanitize_mentions()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn sanitize_mentions(&self) -> String {
|
||||||
|
let input = self.to_string();
|
||||||
|
|
||||||
|
input
|
||||||
.replace("@everyone", "@\u{200B}everyone")
|
.replace("@everyone", "@\u{200B}everyone")
|
||||||
.replace("@here", "@\u{200B}here")
|
.replace("@here", "@\u{200B}here")
|
||||||
.replace("<@", "<@\u{200B}") // user mentions
|
.replace("<@", "<@\u{200B}") // user mentions
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ impl OnMessageHandler<State> for CallMessageHandler {
|
|||||||
.allowed_mentions(None)
|
.allowed_mentions(None)
|
||||||
.username(&profile.name)
|
.username(&profile.name)
|
||||||
.avatar_url(&profile.avatar_url)
|
.avatar_url(&profile.avatar_url)
|
||||||
.content(&content)
|
.content(&content.sanitize_mentions())
|
||||||
.embeds(&embeds)
|
.embeds(&embeds)
|
||||||
.wait()
|
.wait()
|
||||||
.await
|
.await
|
||||||
|
|||||||
Reference in New Issue
Block a user