File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -24,15 +24,15 @@ static const std::string SAFE_CHARS[] =
24
24
CHARS_ALPHA_NUM + " !*'();:@&=+$,/?#[]-_.~%" , // SAFE_CHARS_URI
25
25
};
26
26
27
- std::string SanitizeString (const std::string& str, int rule)
27
+ std::string SanitizeString (std::string_view str, int rule)
28
28
{
29
- std::string strResult ;
30
- for (std::string::size_type i = 0 ; i < str. size (); i++)
31
- {
32
- if (SAFE_CHARS[rule]. find (str[i]) != std::string::npos)
33
- strResult. push_back (str[i]);
29
+ std::string result ;
30
+ for (char c : str) {
31
+ if (SAFE_CHARS[rule]. find (c) != std::string::npos) {
32
+ result. push_back (c);
33
+ }
34
34
}
35
- return strResult ;
35
+ return result ;
36
36
}
37
37
38
38
const signed char p_util_hexdigit[256 ] =
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ enum class ByteUnit : uint64_t {
54
54
* @param[in] rule The set of safe chars to choose (default: least restrictive)
55
55
* @return A new string without unsafe chars
56
56
*/
57
- std::string SanitizeString (const std::string& str, int rule = SAFE_CHARS_DEFAULT);
57
+ std::string SanitizeString (std::string_view str, int rule = SAFE_CHARS_DEFAULT);
58
58
std::vector<unsigned char > ParseHex (std::string_view str);
59
59
signed char HexDigit (char c);
60
60
/* Returns true if each character in str is a hex character, and has an even
You can’t perform that action at this time.
0 commit comments