Improve clean_filename behavior.

GitOrigin-RevId: da29b1a87a27b6bcb7651ae1b261d44dcf18849f
This commit is contained in:
levlam 2018-11-27 04:24:43 +03:00
parent 3e89fac991
commit 7d565e359d
4 changed files with 7 additions and 2 deletions

View File

@ -6765,7 +6765,8 @@ void ContactsManager::on_update_user_online(UserId user_id, tl_object_ptr<telegr
on_update_user_online(u, user_id, std::move(status));
update_user(u, user_id);
if (user_id == get_my_id() && was_online_remote_ != u->was_online) { // only update was_online_remote_ from updateUserStatus
if (user_id == get_my_id() &&
was_online_remote_ != u->was_online) { // only update was_online_remote_ from updateUserStatus
was_online_remote_ = u->was_online;
VLOG(notifications) << "Set was_online_remote to " << was_online_remote_;
G()->td_db()->get_binlog_pmc()->set("my_was_online_remote", to_string(was_online_remote_));

View File

@ -84,6 +84,9 @@ static std::string clean_filename_part(Slice name, int max_length) {
uint32 code;
it = next_utf8_unsafe(it, &code, "clean_filename_part");
if (!is_ok(code)) {
if (prepare_search_character(code) == 0) {
continue;
}
code = ' ';
}
if (new_name.empty() && (code == ' ' || code == '.')) {

View File

@ -18,7 +18,7 @@
#include <cstdint>
#include <sys/types.h> // must be included before sys/event.h, which depends on sys/types.h on FreeBSD
#include <sys/types.h> // must be included before sys/event.h, which depends on sys/types.h on FreeBSD
#include <sys/event.h>

View File

@ -38,4 +38,5 @@ TEST(Misc, clean_filename) {
ASSERT_STREQ(clean_filename("test.exe01234567890123456789...."),
"test.exe01234567890123456789"); // extension may be more then 20 characters
ASSERT_STREQ(clean_filename("....test....asdf"), "test.asdf");
ASSERT_STREQ(clean_filename("കറുപ്പ്.txt"), "കറപപ.txt");
}