Skip to content
Bitcoin Roots

v30.3-roots.1 · Commit 2: [PATCH 02/68] feat(runtime): preserve Roots operator controls on Core 30.3

src/util/strencodings.h

Before: src/util/strencodings.h · After: src/util/strencodings.h

File metadata
index 01063858047cc2c40f8d2d1bcd0f83c18e98db99..6f12543121bdeeb94d45ee1c71e295bce04b7f4b 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. The two line-number columns refer to before and after.

src/util/strencodings.h CHANGED
@@ -33,6 +33,7 @@ enum SafeChars
33
33
  SAFE_CHARS_UA_COMMENT, //!< BIP-0014 subset
34
34
  SAFE_CHARS_FILENAME, //!< Chars allowed in filenames
35
35
  SAFE_CHARS_URI, //!< Chars allowed in URIs (RFC 3986)
36
+ SAFE_CHARS_PRINTABLE, //!< The full set of printable chars
36
37
  };
37
38
 
38
39
  /**
@@ -59,7 +60,7 @@ enum class ByteUnit : uint64_t {
59
60
  * @param[in] rule The set of safe chars to choose (default: least restrictive)
60
61
  * @return A new string without unsafe chars
61
62
  */
62
- std::string SanitizeString(std::string_view str, int rule = SAFE_CHARS_DEFAULT);
63
+ std::string SanitizeString(std::string_view str, int rule = SAFE_CHARS_DEFAULT, bool escape = false);
63
64
  /** Parse the hex string into bytes (uint8_t or std::byte). Ignores whitespace. Returns nullopt on invalid input. */
64
65
  template <typename Byte = std::byte>
65
66
  std::optional<std::vector<Byte>> TryParseHex(std::string_view str);
@@ -162,8 +163,8 @@ constexpr bool IsDigit(char c)
162
163
  * @param[in] c character to test
163
164
  * @return true if the argument is a whitespace character; otherwise false
164
165
  */
165
- constexpr inline bool IsSpace(char c) noexcept {
166
- return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v';
166
+ constexpr inline bool IsSpace(const char c) noexcept {
167
+ return c <= ' ' && (c == ' ' || (c >= '\t' && c <= '\r'));
167
168
  }
168
169
 
169
170
  /**