Revert "refactor: use OutputIterator for url-escaped info hash strings (#3672)"

This reverts commit 479a16787e.
This commit is contained in:
Charles Kerr
2022-08-19 02:18:16 -05:00
parent dde626d5e5
commit 1cf19550ad
4 changed files with 40 additions and 15 deletions

View File

@@ -172,6 +172,29 @@ char const* tr_webGetResponseStr(long code)
}
}
static bool is_rfc2396_alnum(uint8_t ch)
{
return ('0' <= ch && ch <= '9') || ('A' <= ch && ch <= 'Z') || ('a' <= ch && ch <= 'z') || ch == '.' || ch == '-' ||
ch == '_' || ch == '~';
}
void tr_http_escape_sha1(char* out, tr_sha1_digest_t const& digest)
{
for (auto const b : digest)
{
if (is_rfc2396_alnum(uint8_t(b)))
{
*out++ = (char)b;
}
else
{
out = fmt::format_to(out, FMT_STRING("%{:02x}"), unsigned(b));
}
}
*out = '\0';
}
//// URLs
namespace