Ignore invalid UTF-8 hashtags from broken database.
GitOrigin-RevId: 085b83bd70c13d5b4f4d846ca0dba6e9c23b59a7
This commit is contained in:
parent
35bf5e2f32
commit
15cdfb974a
@ -13,6 +13,7 @@
|
||||
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/tl_helpers.h"
|
||||
#include "td/utils/utf8.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
@ -73,6 +74,11 @@ string HashtagHints::get_key() const {
|
||||
}
|
||||
|
||||
void HashtagHints::hashtag_used_impl(const string &hashtag) {
|
||||
if (!check_utf8(hashtag)) {
|
||||
LOG(ERROR) << "Trying to add invalid UTF-8 hashtag \"" << hashtag << '"';
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: may be it should be optimized a little
|
||||
auto key = std::hash<std::string>()(hashtag);
|
||||
hints_.add(key, hashtag);
|
||||
@ -87,7 +93,7 @@ void HashtagHints::from_db(Result<string> data, bool dummy) {
|
||||
std::vector<string> hashtags;
|
||||
auto status = unserialize(hashtags, data.ok());
|
||||
if (status.is_error()) {
|
||||
LOG(ERROR) << status;
|
||||
LOG(ERROR) << "Failed to unserialize hashtag hints: " << status;
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user