guodongxiaren il y a 2 ans
Parent
commit
73465de986
1 fichiers modifiés avec 3 ajouts et 3 suppressions
  1. 3 3
      src/brpc/uri.cpp

+ 3 - 3
src/brpc/uri.cpp

@@ -107,14 +107,14 @@ inline const char* SplitHostAndPort(const char* host_begin,
 // https://datatracker.ietf.org/doc/html/rfc3986#section-2.3
 // https://datatracker.ietf.org/doc/html/rfc3986#section-2.4
 // space is not allowed by rfc3986, but allowed by brpc
-static bool is_valid_char(const char* p) {
+static bool is_valid_char(char p) {
     static const std::unordered_set<char> other_valid_char = {
         ':', '/', '?', '#', '[', ']', '@', '!', '$', '&',
         '\'', '(', ')', '*', '+', ',', ';', '=', '-', '.',
         '_', '~', '%', ' '
     };
 
-    return (isalnum(*p) || other_valid_char.find(*p) != other_valid_char.end());
+    return (isalnum(p) || other_valid_char.count(p));
 }
 
 static bool is_all_spaces(const char* p) {
@@ -178,7 +178,7 @@ int URI::SetHttpURL(const char* url) {
         if (action == URI_PARSE_BREAK) {
             break;
         }
-        if (!is_valid_char(p)) {
+        if (!is_valid_char(*p)) {
             _st.set_error(EINVAL, "invalid character in url");
             return -1;
         } else if (*p == ':') {