fix: mentions parser escapes, emoji parser escapes

This commit is contained in:
trisua 2025-05-06 22:26:44 -04:00
parent 78443cba13
commit 687766f5ee
3 changed files with 8 additions and 10 deletions

View file

@ -25,9 +25,9 @@ pub(crate) type State = Arc<RwLock<(DataManager, Tera, Client)>>;
fn render_markdown(value: &Value, _: &HashMap<String, Value>) -> tera::Result<Value> { fn render_markdown(value: &Value, _: &HashMap<String, Value>) -> tera::Result<Value> {
Ok( Ok(
CustomEmoji::replace(&tetratto_shared::markdown::render_markdown( tetratto_shared::markdown::render_markdown(&CustomEmoji::replace(value.as_str().unwrap()))
value.as_str().unwrap(), .replace("\\@", "@")
)) .replace("%5C@", "@")
.into(), .into(),
) )
} }

View file

@ -309,6 +309,7 @@ impl User {
for char in input.chars() { for char in input.chars() {
if (char == '\\') && !escape { if (char == '\\') && !escape {
escape = true; escape = true;
continue;
} }
if (char == '@') && !escape { if (char == '@') && !escape {

View file

@ -111,15 +111,10 @@ impl CustomEmoji {
let mut chars = input.chars(); let mut chars = input.chars();
while let Some(char) = chars.next() { while let Some(char) = chars.next() {
if escape == true {
buffer.push(char);
continue;
}
if char == '\\' && escape == false { if char == '\\' && escape == false {
escape = true; escape = true;
continue; continue;
} else if char == ':' { } else if char == ':' && escape == false {
let mut community_id: String = String::new(); let mut community_id: String = String::new();
let mut accepting_community_id_chars: bool = true; let mut accepting_community_id_chars: bool = true;
let mut emoji_name: String = String::new(); let mut emoji_name: String = String::new();
@ -164,6 +159,8 @@ impl CustomEmoji {
} else if in_emoji { } else if in_emoji {
buffer.push(char); buffer.push(char);
} }
escape = false;
} }
out out