You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2022/09/01 18:55:24 UTC

[GitHub] [trafficserver] maskit commented on a diff in pull request #9074: Updates to origin side ALPN configuration implementation

maskit commented on code in PR #9074:
URL: https://github.com/apache/trafficserver/pull/9074#discussion_r961000303


##########
src/records/RecHttp.cc:
##########
@@ -859,60 +865,58 @@ convert_alpn_to_wire_format(std::string_view protocols, unsigned char *wire_form
 
   // Parse the comma separated protocol string into a list of protocol names.
   std::vector<std::string_view> alpn_protocols;
-  std::string_view protocol;
-  size_t pos                  = 0;
+  TextView protocol;
   int computed_alpn_array_len = 0;
-  while (pos < protocols.size()) {
-    size_t next_pos = protocols.find(',', pos);
-    if (next_pos == std::string_view::npos) {
-      protocol = protocols.substr(pos);
-      pos      = protocols.size();
-    } else {
-      protocol = protocols.substr(pos, next_pos - pos);
-      pos      = next_pos + 1;
-    }
+
+  // Make sure there are no whitespace characters in the protocols string.
+  if (std::any_of(protocols.begin(), protocols.end(), [](char const c) { return isspace(c); })) {
+    Error("The configured ALPN string contains whitespace characters: %.*s", static_cast<int>(protocols.size()), protocols.data());

Review Comment:
   Current implementation is more accurate actually. Strictly speaking, a protocol id can have spaces and also commas.



-- 
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: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org