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

Commit

Permalink
Merge pull request #6342 from taokayan/fix_table_symbol_parsing
Browse files Browse the repository at this point in the history
fix #6274 false exception msg in symbol parsing
  • Loading branch information
heifner authored Nov 20, 2018
2 parents 6ed2feb + 3ad1dd5 commit 21b307c
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1060,31 +1060,32 @@ uint64_t read_only::get_table_index_name(const read_only::get_table_rows_params&

template<>
uint64_t convert_to_type(const string& str, const string& desc) {
uint64_t value = 0;

try {
value = boost::lexical_cast<uint64_t>(str.c_str(), str.size());
} catch( ... ) {
return boost::lexical_cast<uint64_t>(str.c_str(), str.size());
} catch( ... ) { }

try {
auto trimmed_str = str;
boost::trim(trimmed_str);
name s(trimmed_str);
return s.value;
} catch( ... ) { }

if (str.find(',') != string::npos) { // fix #6274 only match formats like 4,EOS
try {
auto trimmed_str = str;
boost::trim(trimmed_str);
name s(trimmed_str);
value = s.value;
} catch( ... ) {
try {
auto symb = eosio::chain::symbol::from_string(str);
value = symb.value();
} catch( ... ) {
try {
value = ( eosio::chain::string_to_symbol( 0, str.c_str() ) >> 8 );
} catch( ... ) {
EOS_ASSERT( false, chain_type_exception, "Could not convert ${desc} string '${str}' to any of the following: "
"uint64_t, valid name, or valid symbol (with or without the precision)",
("desc", desc)("str", str));
}
}
}
auto symb = eosio::chain::symbol::from_string(str);
return symb.value();
} catch( ... ) { }
}

try {
return ( eosio::chain::string_to_symbol( 0, str.c_str() ) >> 8 );
} catch( ... ) {
EOS_ASSERT( false, chain_type_exception, "Could not convert ${desc} string '${str}' to any of the following: "
"uint64_t, valid name, or valid symbol (with or without the precision)",
("desc", desc)("str", str));
}
return value;
}

abi_def get_abi( const controller& db, const name& account ) {
Expand Down

0 comments on commit 21b307c

Please sign in to comment.