Add limit on chat filter length.

GitOrigin-RevId: 33e627f9792acc429500dd3bdecce6fb4c50e4c4
This commit is contained in:
levlam 2020-05-19 14:30:25 +03:00
parent 2b699a213f
commit 1eb7663769
3 changed files with 11 additions and 7 deletions

View File

@ -650,7 +650,7 @@ chatTypeSecret secret_chat_id:int32 user_id:int32 = ChatType;
//@description Represents a filter of user chats
//@title The title of the filter
//@title The title of the filter; 1-12 characters without line feeds
//@emoji The emoji for short filter representation
//@pinned_chat_ids The chat identifiers of pinned chats in the filtered chat list
//@included_chat_ids The chat identifiers of always included chats in the filtered chat list
@ -667,7 +667,7 @@ chatFilter title:string emoji:string pinned_chat_ids:vector<int53> included_chat
//@description Contains basic information about a chat filter
//@id Unique chat filter identifier
//@title The title of the filter
//@title The title of the filter; 1-12 characters without line feeds
//@emoji The emoji for short filter representation
chatFilterInfo id:int32 title:string emoji:string = ChatFilterInfo;

View File

@ -15154,7 +15154,10 @@ Result<unique_ptr<MessagesManager::DialogFilter>> MessagesManager::create_dialog
return Status::Error(400, "Too much pinned chats");
}
dialog_filter->title = std::move(filter->title_);
dialog_filter->title = clean_name(std::move(filter->title_), MAX_DIALOG_FILTER_TITLE_LENGTH);
if (dialog_filter->title.empty()) {
return Status::Error(400, "Title must not be empty");
}
dialog_filter->emoji = std::move(filter->emoji_);
dialog_filter->exclude_muted = filter->exclude_muted_;
dialog_filter->exclude_read = filter->exclude_read_;

View File

@ -1516,10 +1516,11 @@ class MessagesManager : public Actor {
static constexpr int32 MIN_SEARCH_PUBLIC_DIALOG_PREFIX_LEN = 5; // server side limit
static constexpr int32 MIN_CHANNEL_DIFFERENCE = 10;
static constexpr int32 MAX_CHANNEL_DIFFERENCE = 100;
static constexpr int32 MAX_BOT_CHANNEL_DIFFERENCE = 100000; // server side limit
static constexpr int32 MAX_RECENT_FOUND_DIALOGS = 20; // some reasonable value
static constexpr size_t MAX_TITLE_LENGTH = 128; // server side limit for chat title
static constexpr size_t MAX_DESCRIPTION_LENGTH = 255; // server side limit for chat description
static constexpr int32 MAX_BOT_CHANNEL_DIFFERENCE = 100000; // server side limit
static constexpr int32 MAX_RECENT_FOUND_DIALOGS = 20; // some reasonable value
static constexpr size_t MAX_TITLE_LENGTH = 128; // server side limit for chat title
static constexpr size_t MAX_DESCRIPTION_LENGTH = 255; // server side limit for chat description
static constexpr size_t MAX_DIALOG_FILTER_TITLE_LENGTH = 12; // server side limit for dialog filter title
static constexpr int64 SPONSORED_DIALOG_ORDER = static_cast<int64>(2147483647) << 32;
static constexpr int32 MIN_PINNED_DIALOG_DATE = 2147000000; // some big date
static constexpr int32 MAX_PRIVATE_MESSAGE_TTL = 60; // server side limit