v29.4-roots.4 · Commit 2: [PATCH 02/37] runtime: preserve shared operator controls
src/util/strencodings.h
Before: src/util/strencodings.h · After: src/util/strencodings.h
File metadata
index d0809162fafe50e38662a3798ede4c350a984558..28f59c4011aafed102d703050d6fac9e08181076 100644
Download original patch · Release notes
Diff rows 1–25 of 25. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.
src/util/strencodings.h
CHANGED
|
@@ -33,6 +33,7 @@ enum SafeChars
|
|
| 33 |
SAFE_CHARS_UA_COMMENT, //!< BIP-0014 subset
|
| 34 |
SAFE_CHARS_FILENAME, //!< Chars allowed in filenames
|
| 35 |
SAFE_CHARS_URI, //!< Chars allowed in URIs (RFC 3986)
|
|
|
|
| 36 |
};
|
| 37 |
|
| 38 |
/**
|
|
@@ -59,7 +60,7 @@ enum class ByteUnit : uint64_t {
|
|
| 59 |
* @param[in] rule The set of safe chars to choose (default: least restrictive)
|
| 60 |
* @return A new string without unsafe chars
|
| 61 |
*/
|
| 62 |
-
std::string SanitizeString(std::string_view str, int rule = SAFE_CHARS_DEFAULT);
|
| 63 |
/** Parse the hex string into bytes (uint8_t or std::byte). Ignores whitespace. Returns nullopt on invalid input. */
|
| 64 |
template <typename Byte = std::byte>
|
| 65 |
std::optional<std::vector<Byte>> TryParseHex(std::string_view str);
|
|
@@ -163,8 +164,8 @@ constexpr bool IsDigit(char c)
|
|
| 163 |
* @param[in] c character to test
|
| 164 |
* @return true if the argument is a whitespace character; otherwise false
|
| 165 |
*/
|
| 166 |
-
constexpr inline bool IsSpace(char c) noexcept {
|
| 167 |
-
return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v';
|
| 168 |
}
|
| 169 |
|
| 170 |
/**
|
|
|
|
| 33 |
SAFE_CHARS_UA_COMMENT, //!< BIP-0014 subset
|
| 34 |
SAFE_CHARS_FILENAME, //!< Chars allowed in filenames
|
| 35 |
SAFE_CHARS_URI, //!< Chars allowed in URIs (RFC 3986)
|
| 36 |
+
SAFE_CHARS_PRINTABLE, //!< The full set of printable chars
|
| 37 |
};
|
| 38 |
|
| 39 |
/**
|
|
|
|
| 60 |
* @param[in] rule The set of safe chars to choose (default: least restrictive)
|
| 61 |
* @return A new string without unsafe chars
|
| 62 |
*/
|
| 63 |
+
std::string SanitizeString(std::string_view str, int rule = SAFE_CHARS_DEFAULT, bool escape = false);
|
| 64 |
/** Parse the hex string into bytes (uint8_t or std::byte). Ignores whitespace. Returns nullopt on invalid input. */
|
| 65 |
template <typename Byte = std::byte>
|
| 66 |
std::optional<std::vector<Byte>> TryParseHex(std::string_view str);
|
|
|
|
| 164 |
* @param[in] c character to test
|
| 165 |
* @return true if the argument is a whitespace character; otherwise false
|
| 166 |
*/
|
| 167 |
+
constexpr inline bool IsSpace(const char c) noexcept {
|
| 168 |
+
return c <= ' ' && (c == ' ' || (c >= '\t' && c <= '\r'));
|
| 169 |
}
|
| 170 |
|
| 171 |
/**
|