From f56d80236eec9f34ea8e89fcb5a62e61ad573322 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 3 Dec 2018 17:31:16 +0400 Subject: [PATCH] Ignore inline bot with overlapping markdown. --- Telegram/SourceFiles/chat_helpers/message_field.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/chat_helpers/message_field.cpp b/Telegram/SourceFiles/chat_helpers/message_field.cpp index 4babe0754..9c77df998 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.cpp +++ b/Telegram/SourceFiles/chat_helpers/message_field.cpp @@ -341,7 +341,8 @@ bool HasSendText(not_null field) { InlineBotQuery ParseInlineBotQuery(not_null field) { auto result = InlineBotQuery(); - const auto &text = field->getTextWithTags().text; + const auto &full = field->getTextWithTags(); + const auto &text = full.text; const auto textLength = text.size(); auto inlineUsernameStart = 1; @@ -367,6 +368,11 @@ InlineBotQuery ParseInlineBotQuery(not_null field) { validInlineUsername = text[inlineUsernameEnd].isSpace(); } if (validInlineUsername) { + if (!full.tags.isEmpty() + && (full.tags.front().offset + < inlineUsernameStart + inlineUsernameLength)) { + return InlineBotQuery(); + } auto username = text.midRef(inlineUsernameStart, inlineUsernameLength); if (username != result.username) { result.username = username.toString();