MCPcopy Create free account
hub / github.com/TelegramMessenger/cocoon / process_string_hex

Function process_string_hex

runners/helpers/ValidateRequest.cpp:792–807  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

790}
791
792static td::Status process_string_hex(Ctx &ctx) {
793 if (!ctx.is_string()) {
794 return td::Status::Error(ton::ErrorCode::protoviolation, PSTRING() << ctx.path() << " must be a string");
795 }
796 TRY_RESULT(v, ctx.get_string());
797 if (v.size() % 2 != 0) {
798 return td::Status::Error(ton::ErrorCode::protoviolation, PSTRING() << ctx.path() << " must be a hex string");
799 }
800 for (auto c : v) {
801 bool is_hex = (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
802 if (!is_hex) {
803 return td::Status::Error(ton::ErrorCode::protoviolation, PSTRING() << ctx.path() << " must be a hex string");
804 }
805 }
806 return td::Status::OK();
807}
808
809static td::Status process_string_url_or_b64(Ctx &ctx) {
810 if (!ctx.is_string()) {

Callers

nothing calls this directly

Calls 2

is_stringMethod · 0.45
get_stringMethod · 0.45

Tested by

no test coverage detected