-
-
Notifications
You must be signed in to change notification settings - Fork 49
Fix CI failures: initialize submodules and fix ssl_merger Content-Length parsing #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
2a36514
f5e8119
5718cf1
573cc1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,11 +79,12 @@ impl SSLMerger { | |
| // For non-chunked, check Content-Length | ||
| if let Some(cl_start) = headers.to_lowercase().find("content-length:") { | ||
| let cl_line = &headers[cl_start..]; | ||
| if let Some(cl_end) = cl_line.find("\r\n") { | ||
| let cl_value = &cl_line[15..cl_end].trim(); | ||
| if let Ok(content_length) = cl_value.parse::<usize>() { | ||
| return body.len() >= content_length; | ||
| } | ||
| // Find the end of the Content-Length header line | ||
| // It could be followed by \r\n (if there are more headers) or end of headers | ||
| let cl_end = cl_line.find("\r\n").unwrap_or(cl_line.len()); | ||
| let cl_value = cl_line[15..cl_end].trim(); | ||
| if let Ok(content_length) = cl_value.parse::<usize>() { | ||
|
||
| return body.len() >= content_length; | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Content-Length detection uses
headers.to_lowercase().find("content-length:"), which can match inside other header names (e.g.,X-Content-Length) or within a header value, and then slices from that byte offset. This can cause incorrect Content-Length parsing and premature message completion. Consider parsing headers line-by-line (split on\r\n) and matchingContent-Lengthonly at the start of a header line (case-insensitive), or at least ensuring the match is at start-of-string or preceded by\r\n.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot apply changes based on this feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 573cc1c. Changed implementation to parse headers line-by-line using
split("\r\n")and matchContent-Lengthonly at the start of header lines withstarts_with(), preventing false matches in other header names or values.