This is #18130 rebased.
TrimStringis an existing alternative.
Note
TrimStringuses" \f\n\r\t\v"as the pattern, which is consistent with the default behavior ofstd::isspace. See: https://en.cppreference.com/w/cpp/string/byte/isspace
This is #18130 rebased.
TrimStringis an existing alternative.
Note
TrimStringuses" \f\n\r\t\v"as the pattern, which is consistent with the default behavior ofstd::isspace. See: https://en.cppreference.com/w/cpp/string/byte/isspace
Note the only use of readStdin is fed to DecodeHexTx, which fails in
IsHex on non-hex characters as recorded in p_util_hexdigit.
Concept ACK
utACK 696c76d6604c9c4faddfc4b6684e2788bb577ba6
Very happy to see a reduction in our locale dependency!
I think we'll be able to have an empty KNOWN_VIOLATIONS list in test/lint/lint-locale-dependence.sh by the end of the year. That would be awesome! :)
ACK 696c76d6604c9c4faddfc4b6684e2788bb577ba6
130 | @@ -130,8 +131,7 @@ static bool RPCAuthorized(const std::string& strAuth, std::string& strAuthUserna 131 | return false; 132 | if (strAuth.substr(0, 6) != "Basic ") 133 | return false; 134 | - std::string strUserPass64 = strAuth.substr(6); 135 | - boost::trim(strUserPass64); 136 | + std::string strUserPass64 = TrimString(strAuth.substr(6)); 137 | std::string strUserPass = DecodeBase64(strUserPass64);
9355186 nit, these can be const
- std::string strUserPass64 = TrimString(strAuth.substr(6));
- std::string strUserPass = DecodeBase64(strUserPass64);
+ const std::string strUserPass64 = TrimString(strAuth.substr(6));
+ const std::string strUserPass = DecodeBase64(strUserPass64);
ACK 696c76d6604c9c4faddfc4b6684e2788bb577ba6
Code-review ACK 696c76d6604c9c4faddfc4b6684e2788bb577ba6
Happy to also re-ACK if Jon's suggestion of declaring strUserPass{64} as const (https://github.com/bitcoin/bitcoin/pull/22859#discussion_r702292854) is applied.
771 | @@ -772,9 +772,7 @@ static std::string readStdin() 772 | if (ferror(stdin)) 773 | throw std::runtime_error("error reading stdin"); 774 | 775 | - boost::algorithm::trim_right(ret); 776 | - 777 | - return ret; 778 | + return TrimString(ret);
This SHOULD be a locale trim!
Why? It isn't trying to read native-language text.
It's interacting with the CLI, which is expected to behave in the user's configured locale.
When processing text, or other locale-formatted things like dates/..., I can see that. But this is just accepting hex-encoded tx data?