Skip to content

Commit 018ce8e

Browse files
authored
cast to unsigned char before ctype calls in is_hex and is_token_char (#2469)
1 parent 77bdf79 commit 018ce8e

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

httplib.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4386,7 +4386,7 @@ inline bool set_socket_opt_time(socket_t sock, int level, int optname,
43864386
}
43874387

43884388
inline bool is_hex(char c, int &v) {
4389-
if (isdigit(c)) {
4389+
if (isdigit(static_cast<unsigned char>(c))) {
43904390
v = c - '0';
43914391
return true;
43924392
} else if ('A' <= c && c <= 'F') {
@@ -8244,7 +8244,7 @@ inline bool is_multipart_boundary_chars_valid(const std::string &boundary) {
82448244
auto valid = true;
82458245
for (size_t i = 0; i < boundary.size(); i++) {
82468246
auto c = boundary[i];
8247-
if (!std::isalnum(c) && c != '-' && c != '_') {
8247+
if (!std::isalnum(static_cast<unsigned char>(c)) && c != '-' && c != '_') {
82488248
valid = false;
82498249
break;
82508250
}
@@ -8729,9 +8729,10 @@ class ContentProviderAdapter {
87298729
namespace fields {
87308730

87318731
inline bool is_token_char(char c) {
8732-
return std::isalnum(c) || c == '!' || c == '#' || c == '$' || c == '%' ||
8733-
c == '&' || c == '\'' || c == '*' || c == '+' || c == '-' ||
8734-
c == '.' || c == '^' || c == '_' || c == '`' || c == '|' || c == '~';
8732+
return std::isalnum(static_cast<unsigned char>(c)) || c == '!' || c == '#' ||
8733+
c == '$' || c == '%' || c == '&' || c == '\'' || c == '*' ||
8734+
c == '+' || c == '-' || c == '.' || c == '^' || c == '_' || c == '`' ||
8735+
c == '|' || c == '~';
87358736
}
87368737

87378738
inline bool is_token(const std::string &s) {

0 commit comments

Comments
 (0)