Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
fix string decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
huangminghuang committed Jan 27, 2021
1 parent ec79140 commit b8736be
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2409,7 +2409,13 @@ void set_kv_next_key(const string& encode_type, const string& index_type, read_o
result.next_key = result.next_key_bytes;
}else if (encode_type == "string") {
result.next_key = boost::algorithm::unhex(result.next_key_bytes);
boost::algorithm::trim_right_if( result.next_key, []( char c ){ return c == '\0'; } );
/// restore the string following the encoding rule from `template <typename S> to_key(std::string, S&)` in abieos to_key.hpp
boost::replace_all(result.next_key, "\0\1", "\0");
// remove trailing '\0\0'
auto sz = result.next_key.size();
if (sz >=2 && result.next_key[sz-1] == '\0' && result.next_key[sz-2] == '\0')
result.next_key.resize(sz-2);

}else if (encode_type == "name") {
uint64_t ull;
convert_from_bytes(ull, result.next_key_bytes);
Expand Down

0 comments on commit b8736be

Please sign in to comment.