Ignore inline bot with overlapping markdown.

This commit is contained in:
John Preston 2018-12-03 17:31:16 +04:00
parent 1b19e870c0
commit f56d80236e
1 changed files with 7 additions and 1 deletions

View File

@ -341,7 +341,8 @@ bool HasSendText(not_null<const Ui::InputField*> field) {
InlineBotQuery ParseInlineBotQuery(not_null<const Ui::InputField*> field) { InlineBotQuery ParseInlineBotQuery(not_null<const Ui::InputField*> field) {
auto result = InlineBotQuery(); auto result = InlineBotQuery();
const auto &text = field->getTextWithTags().text; const auto &full = field->getTextWithTags();
const auto &text = full.text;
const auto textLength = text.size(); const auto textLength = text.size();
auto inlineUsernameStart = 1; auto inlineUsernameStart = 1;
@ -367,6 +368,11 @@ InlineBotQuery ParseInlineBotQuery(not_null<const Ui::InputField*> field) {
validInlineUsername = text[inlineUsernameEnd].isSpace(); validInlineUsername = text[inlineUsernameEnd].isSpace();
} }
if (validInlineUsername) { if (validInlineUsername) {
if (!full.tags.isEmpty()
&& (full.tags.front().offset
< inlineUsernameStart + inlineUsernameLength)) {
return InlineBotQuery();
}
auto username = text.midRef(inlineUsernameStart, inlineUsernameLength); auto username = text.midRef(inlineUsernameStart, inlineUsernameLength);
if (username != result.username) { if (username != result.username) {
result.username = username.toString(); result.username = username.toString();