Repository navigation
fix(lambda-events): accept non-ASCII header values with http 1.6 - #1200
Open
ranjithguggilla wants to merge 1 commit into
Open
ranjithguggilla wants to merge 1 commit into
ranjithguggilla wants to merge 1 commit into
Conversation
http 1.6.0 changed the string conversions of `HeaderValue` (`from_str`, `str::parse`) to reject non-ASCII characters. The header deserializers parsed JSON strings that way, so a request with a UTF-8 header value failed to deserialize, and `test_serialize_utf8_headers` fails on main with the current http release. Build the values with `HeaderValue::from_bytes`, which still accepts bytes above 0x7F and still rejects control characters. Do the same for the API Gateway v2 `cookies` list in lambda-http, where a non-ASCII cookie made the whole Cookie header disappear.
4 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #: none that I could find. Related but different: #1188 (control characters).
Description of changes:
http 1.6.0 changed
HeaderValue::from_str/str::parseso they reject non-ASCII. The header deserializers inaws_lambda_eventsused.parse(), so an API Gateway, ALB, or VPC Lattice event with a UTF-8 header value fails to deserialize. Because the repo has noCargo.lock, CI on main now failstest_serialize_utf8_headersfor the same reason.This switches those three call sites to
HeaderValue::from_bytes, which still accepts bytes above 0x7F and still rejects control characters. Same change for the API Gateway v2 cookie join inlambda-http, where one non-ASCII cookie was dropping the wholeCookieheader.Added coverage for multi-value UTF-8 headers, comma-separated UTF-8 headers (VPC Lattice), non-ASCII cookies, and keeping the control-character rejection.
Checked locally against http 1.6.0:
cargo +nightly fmt --all -- --check,cargo clippy --workspace --all-features -- -D warnings,cargo test --all-featuresforaws_lambda_events(238) andlambda_http(98), andmake check-event-features.By submitting this pull request
cargo +nightly fmt.cargo clippy --fix.