Skip to content

Commit

Permalink
Fix handling of null formattedText.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 5bcde391288909e3119988cf94e223511cd22db4
  • Loading branch information
levlam committed Jan 31, 2018
1 parent 40fa9f1 commit 5c81c0d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions td/telegram/MessagesManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13771,6 +13771,9 @@ Status MessagesManager::fix_text_message(string &text, vector<MessageEntity> &en
Result<FormattedText> MessagesManager::process_input_caption(DialogId dialog_id,
tl_object_ptr<td_api::formattedText> &&text,
bool is_bot) const {
if (text == nullptr) {
return {};
}
TRY_RESULT(entities, get_message_entities(td_->contacts_manager_.get(), std::move(text->entities_)));
TRY_STATUS(fix_text_message(text->text_, entities, true, false, need_skip_bot_commands(dialog_id, is_bot), false));
return FormattedText{std::move(text->text_), std::move(entities)};
Expand All @@ -13782,6 +13785,15 @@ Result<InputMessageText> MessagesManager::process_input_message_text(
CHECK(input_message_content != nullptr);
CHECK(input_message_content->get_id() == td_api::inputMessageText::ID);
auto input_message_text = static_cast<td_api::inputMessageText *>(input_message_content.get());
if (input_message_text->text_ == nullptr) {
if (for_draft) {
return InputMessageText{FormattedText{},
input_message_text->disable_web_page_preview_, input_message_text->clear_draft_};
}

return Status::Error(400, "Message text can't be empty");
}

TRY_RESULT(entities,
get_message_entities(td_->contacts_manager_.get(), std::move(input_message_text->text_->entities_)));
TRY_STATUS(fix_text_message(input_message_text->text_->text_, entities, for_draft, false,
Expand Down

0 comments on commit 5c81c0d

Please sign in to comment.