Fix returning invalid Unicode from parse_html.
GitOrigin-RevId: 9277022a53d23ac5c3eb1427eb48bd886b789d09
This commit is contained in:
parent
041896ab8d
commit
6dbef6ef76
@ -1616,6 +1616,12 @@ Result<vector<MessageEntity>> parse_html(string &text) {
|
||||
utf16_offset += utf16_entity_length;
|
||||
}
|
||||
}
|
||||
if (!check_utf8(result)) {
|
||||
return Status::Error(400,
|
||||
"Text contains invalid Unicode characters after decoding HTML entities, check for unmatched "
|
||||
"surrogate code units");
|
||||
}
|
||||
|
||||
text = result;
|
||||
return entities;
|
||||
}
|
||||
|
@ -2365,8 +2365,12 @@ class CliClient final : public Actor {
|
||||
execute(make_tl_object<td_api::getTextEntities>(args));
|
||||
} else if (op == "pte") {
|
||||
send_request(make_tl_object<td_api::parseTextEntities>(args, make_tl_object<td_api::textParseModeMarkdown>()));
|
||||
} else if (op == "pteh") {
|
||||
send_request(make_tl_object<td_api::parseTextEntities>(args, make_tl_object<td_api::textParseModeHTML>()));
|
||||
} else if (op == "ptes") {
|
||||
execute(make_tl_object<td_api::parseTextEntities>(args, make_tl_object<td_api::textParseModeMarkdown>()));
|
||||
} else if (op == "ptehs") {
|
||||
execute(make_tl_object<td_api::parseTextEntities>(args, make_tl_object<td_api::textParseModeHTML>()));
|
||||
} else if (op == "gfmt") {
|
||||
send_request(make_tl_object<td_api::getFileMimeType>(trim(args)));
|
||||
} else if (op == "gfe") {
|
||||
|
Loading…
Reference in New Issue
Block a user