1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-23 08:13:27 +00:00

Fix off-by-one mistake in gtr_str_strip() (#2057)

Was always trimming last non-whitespace char from the input text.

Fixes: #2027
This commit is contained in:
Mike Gelfand 2021-10-28 23:52:25 +03:00 committed by GitHub
parent 1d0993c3a5
commit 5da0a5d59b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -154,7 +154,7 @@ inline T gtr_str_strip(T const& text)
{ {
auto const new_begin = text.find_first_not_of("\t\n\v\f\r "); auto const new_begin = text.find_first_not_of("\t\n\v\f\r ");
auto const new_end = text.find_last_not_of("\t\n\v\f\r "); auto const new_end = text.find_last_not_of("\t\n\v\f\r ");
return new_begin == T::npos ? T() : text.substr(new_begin, new_end == T::npos ? new_end : new_end - new_begin); return new_begin == T::npos ? T() : text.substr(new_begin, new_end == T::npos ? new_end : new_end - new_begin + 1);
} }
namespace gtr_detail namespace gtr_detail