From 4983b8e9a3b052afb816e3edf66c13a3498bccd0 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 6 Nov 2023 01:51:51 +0300 Subject: [PATCH] Don't remove newline character after Pre entities. --- td/telegram/MessageEntity.cpp | 3 --- test/message_entities.cpp | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/td/telegram/MessageEntity.cpp b/td/telegram/MessageEntity.cpp index 485bd7d6b..83712811a 100644 --- a/td/telegram/MessageEntity.cpp +++ b/td/telegram/MessageEntity.cpp @@ -2737,9 +2737,6 @@ static FormattedText parse_pre_entities_v3(Slice text) { result.append(text.begin() + entity_begin, end_tag_begin - entity_begin); utf16_offset += entity_length; i = end_tag_end - 1; - if (end_tag_end < size && text[end_tag_end] == '\n') { - i++; - } is_found = true; break; } else { diff --git a/test/message_entities.cpp b/test/message_entities.cpp index bdf9b84e3..e5ad6e11e 100644 --- a/test/message_entities.cpp +++ b/test/message_entities.cpp @@ -1843,11 +1843,11 @@ TEST(MessageEntities, parse_markdown_v3) { {{td::MessageEntity::Type::Pre, 4, 10}}); check_parse_markdown_v3("asd\naba```\nsome code\n```cabab", "asd\naba\nsome code\ncabab", {{td::MessageEntity::Type::Pre, 7, 11}}); - check_parse_markdown_v3("asd\naba```\nsome code\n```\ncabab", "asd\naba\nsome code\ncabab", + check_parse_markdown_v3("asd\naba```\nsome code\n```\ncabab", "asd\naba\nsome code\n\ncabab", {{td::MessageEntity::Type::Pre, 7, 11}}); - check_parse_markdown_v3("asd\naba```a b\nsome code\n```\ncabab", "asd\nabaa b\nsome code\ncabab", + check_parse_markdown_v3("asd\naba```a b\nsome code\n```\ncabab", "asd\nabaa b\nsome code\n\ncabab", {{td::MessageEntity::Type::Pre, 7, 14}}); - check_parse_markdown_v3("asd\naba```a!@#$%^&*(b\nsome code\n```\ncabab", "asd\nabasome code\ncabab", + check_parse_markdown_v3("asd\naba```a!@#$%^&*(b\nsome code\n```\ncabab", "asd\nabasome code\n\ncabab", {{td::MessageEntity::Type::PreCode, 7, 10, "a!@#$%^&*(b"}}); check_parse_markdown_v3("```aba\n```", "aba\n", {{td::MessageEntity::Type::Pre, 0, 4}}); check_parse_markdown_v3("```\n```", "\n", {{td::MessageEntity::Type::Pre, 0, 1}});