Skip to content

Conversation

fanquake
Copy link
Member

@fanquake fanquake commented Sep 2, 2021

This is #18130 rebased.

TrimString is an existing alternative.

Note TrimString uses " \f\n\r\t\v" as the pattern, which is consistent with the default behavior of std::isspace. See: https://en.cppreference.com/w/cpp/string/byte/isspace

Empact and others added 3 commits September 2, 2021 13:17
Note the only use of readStdin is fed to DecodeHexTx, which fails in
IsHex on non-hex characters as recorded in p_util_hexdigit.
@fanquake
Copy link
Member Author

fanquake commented Sep 2, 2021

cc @practicalswift @l2a5b1

@jonatack
Copy link
Member

jonatack commented Sep 3, 2021

Concept ACK

@jb55
Copy link
Contributor

jb55 commented Sep 3, 2021

utACK 696c76d

@practicalswift
Copy link
Contributor

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 696c76d

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 696c76d

@@ -130,8 +131,7 @@ static bool RPCAuthorized(const std::string& strAuth, std::string& strAuthUserna
return false;
if (strAuth.substr(0, 6) != "Basic ")
return false;
std::string strUserPass64 = strAuth.substr(6);
boost::trim(strUserPass64);
std::string strUserPass64 = TrimString(strAuth.substr(6));
std::string strUserPass = DecodeBase64(strUserPass64);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code-review ACK 696c76d

Happy to also re-ACK if Jon's suggestion of declaring strUserPass{64} as const (#22859 (comment)) is applied.

@fanquake fanquake merged commit 6490a3e into bitcoin:master Sep 5, 2021
@fanquake fanquake deleted the 18130_rebased branch September 5, 2021 03:14
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 7, 2021
boost::algorithm::trim_right(ret);

return ret;
return TrimString(ret);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This SHOULD be a locale trim!

Copy link
Member

@sipa sipa Sep 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? It isn't trying to read native-language text.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's interacting with the CLI, which is expected to behave in the user's configured locale.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When processing text, or other locale-formatted things like dates/..., I can see that. But this is just accepting hex-encoded tx data?

@bitcoin bitcoin locked and limited conversation to collaborators Oct 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants