From 3dce19ca2bca35217ce751a9f61336c8ca48caa5 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 2 Mar 2023 19:57:11 +0300 Subject: [PATCH] Check that button text isn't empty. --- td/telegram/ReplyMarkup.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/td/telegram/ReplyMarkup.cpp b/td/telegram/ReplyMarkup.cpp index 9fb28b48b..864d7c95e 100644 --- a/td/telegram/ReplyMarkup.cpp +++ b/td/telegram/ReplyMarkup.cpp @@ -443,6 +443,9 @@ static Result get_keyboard_button(tl_object_ptrtext_)) { return Status::Error(400, "Keyboard button text must be encoded in UTF-8"); } + if (button->text_.empty()) { + return Status::Error(400, "Keyboard button text must be non-empty"); + } KeyboardButton current_button; current_button.text = std::move(button->text_); @@ -527,16 +530,18 @@ static Result get_inline_keyboard_button(tl_object_ptrtext_)) { - return Status::Error(400, "Keyboard button text must be encoded in UTF-8"); + return Status::Error(400, "Inline keyboard button text must be encoded in UTF-8"); + } + if (button->text_.empty()) { + return Status::Error(400, "Inline keyboard button text must be non-empty"); + } + if (button->type_ == nullptr) { + return Status::Error(400, "Inline keyboard button type must be non-empty"); } InlineKeyboardButton current_button; current_button.text = std::move(button->text_); - if (button->type_ == nullptr) { - return Status::Error(400, "Inline keyboard button type must be non-empty"); - } - int32 button_type_id = button->type_->get_id(); switch (button_type_id) { case td_api::inlineKeyboardButtonTypeUrl::ID: {