zwoop commented on code in PR #13420:
URL: https://github.com/apache/trafficserver/pull/13420#discussion_r4428861067


##########
src/proxy/hdrs/VersionConverter.cc:
##########
@@ -229,14 +251,35 @@ VersionConverter::_convert_req_from_2_to_1(HTTPHdr 
&header) const
     // :path
     if (MIMEField *field = header.field_find(PSEUDO_HEADER_PATH);
         field != nullptr && field->value_is_valid(is_control_BIT | is_ws_BIT)) 
{
-      auto path{field->value_get()};
+      auto                  value{field->value_get()};
+      ts::LocalBuffer<char> buf(value.length());
+      std::string_view      path{buf.data(), value.length()};
+      auto                 *url = header.m_http->u.req.m_url_impl;
+
+      // Copy out, as for :authority.
+      std::copy(value.begin(), value.end(), buf.data());
+
+      // Split as url_parse_http() would, so cache keys and remap see the same 
fields.
+      auto hpos = path.find('#');
+
+      if (hpos != std::string_view::npos) {
+        url->set_fragment(header.m_heap, path.substr(hpos + 1), true);
+        path = path.substr(0, hpos);
+      }
+
+      auto qpos = path.find('?');
+
+      if (qpos != std::string_view::npos) {
+        url->set_query(header.m_heap, path.substr(qpos + 1), true);
+        path = path.substr(0, qpos);
+      }
 
-      // cut first '/' if there, because `url_print()` add '/' before printing 
path
-      if (path.starts_with("/"sv)) {
+      // url_parse_http() strips every leading '/'; url_print() re-adds 
exactly one.
+      while (path.starts_with("/"sv)) {
         path.remove_prefix(1);
       }

Review Comment:
   Fixed in 54e35de5b2. The converter strips one leading `/` again, and the 
gate falls back while the path still starts with `/`, so `parse_req()` applies 
`request_line_max_size` to the original length before `url_parse_http()` strips 
the rest. The 1,100-slash case is now in `h2_request_line_limit.test.yaml` and 
expects 414.



-- 
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]

Reply via email to