From 67e3d3fbbe2999790b07b3f0c894b9ed01a79633 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 11 Nov 2022 01:18:01 +0100 Subject: Matrix: fix replying to custom emoji making the custom emoji also display in the reply text --- src/plugins/Matrix.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 28b4823..fd5026a 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -2630,7 +2630,7 @@ namespace QuickMedia { } else if(html_parser->tag_name.size == 4 && memcmp(html_parser->tag_name.data, "code", 4) == 0) { parse_userdata.inside_code_tag = false; } else if(html_parser->tag_name.size == 3 && memcmp(html_parser->tag_name.data, "img", 3) == 0) { - if(parse_userdata.matrix && parse_userdata.inside_img_tag && parse_userdata.img_src.size() > 0) { + if(parse_userdata.allow_formatted_text && parse_userdata.matrix && parse_userdata.mx_reply_depth == 0 && parse_userdata.inside_img_tag && parse_userdata.img_src.size() > 0) { std::string image_url(parse_userdata.img_src); html_unescape_sequences(image_url); mgl::vec2i img_size = parse_userdata.img_size; @@ -2660,7 +2660,7 @@ namespace QuickMedia { const std::string height(html_parser->attribute_value.data, html_parser->attribute_value.size); parse_userdata.img_size.y = atoi(height.c_str()); } - } else if(!parse_userdata.allow_formatted_text && parse_userdata.inside_img_tag && html_parser->attribute_key.size == 3 && memcmp(html_parser->attribute_key.data, "alt", 3) == 0) { + } else if(!parse_userdata.allow_formatted_text && parse_userdata.inside_img_tag && parse_userdata.mx_reply_depth == 0 && html_parser->attribute_key.size == 3 && memcmp(html_parser->attribute_key.data, "alt", 3) == 0) { std::string text_to_add(html_parser->attribute_value.data, html_parser->attribute_value.size); html_unescape_sequences(text_to_add); parse_userdata.result += std::move(text_to_add); @@ -3748,11 +3748,13 @@ namespace QuickMedia { html_escape_sequences(url); std::string width = std::to_string(it.second.size.x); std::string height = std::to_string(it.second.size.y); - std::string tag = "\"""; + std::string tag = "\"""; string_replace_all(str, keybind, tag); } } + // TODO: remove first/last newspace in codeblock. + std::string Matrix::body_to_formatted_body(RoomData *room, const std::string &body) { std::unordered_map custom_emojis_copy; { -- cgit v1.2.3