Sanitize mentions on call

This commit is contained in:
2025-08-18 21:01:27 -03:00
parent 54217f1d69
commit 1149dd5bb4
4 changed files with 16 additions and 4 deletions
+13 -1
View File
@@ -11,6 +11,12 @@ pub trait SanitizeDiscordMarkdown {
/// Returns:
/// [`String`] - The sanitized 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
@@ -40,7 +46,13 @@ where
};
// 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("@here", "@\u{200B}here")
.replace("<@", "<@\u{200B}") // user mentions