zyearn commented on a change in pull request #1506:
URL: https://github.com/apache/incubator-brpc/pull/1506#discussion_r683750911



##########
File path: src/brpc/uri.cpp
##########
@@ -98,6 +102,21 @@ inline const char* SplitHostAndPort(const char* host_begin,
     return host_end;
 }
 
+// valid characters in URL
+// https://datatracker.ietf.org/doc/html/rfc3986#section-2.1
+// 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 const std::unordered_set<char> other_valid_char = {
+        ':', '/', '?', '#', '[', ']', '@', '!', '$', '&',
+        '\'', '(', ')', '*', '+', ',', ';', '=', '-', '.',
+        '_', '~', '%', ' '
+    };
+
+    return (isalnum(*p) || other_valid_char.find(*p) != 
other_valid_char.end());

Review comment:
       可以直接other_valid_char.count(*p)

##########
File path: src/brpc/uri.cpp
##########
@@ -98,6 +102,21 @@ inline const char* SplitHostAndPort(const char* host_begin,
     return host_end;
 }
 
+// valid characters in URL
+// https://datatracker.ietf.org/doc/html/rfc3986#section-2.1
+// 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) {

Review comment:
       这个函数传char c感觉更直观一点?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to