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();