Skip to content
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

Add tests for quoted strings in headers #986

Merged

Conversation

adamthom-amzn
Copy link
Contributor

@adamthom-amzn adamthom-amzn commented Nov 16, 2021

Description of changes:
RFC 7230 sec 3.2.6 defines header values as potentially quoted strings, which
makes commas in header values unambiguous. It's also the only way to escape a
reserved character. This adds a test for list values with a comma and for list
values with escaped double quotes.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@adamthom-amzn adamthom-amzn requested a review from a team as a code owner November 16, 2021 19:43
headers: {
"X-StringList": """
a, "b,c", "\"def\""
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go on the previous line. By putting it on the next line, it's inserting a "\n".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but if I turn that into:

        headers: {
            "X-StringList": """
            a, "b,c", "\"def\"""""
        },

Then the entire file doesn't parse. I can work around this by flipping the order of the parameters, or by adding a whitespace (which is ignored according to spec)

headers: {
"X-StringList": """
a, "b,c", "\"def\""
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue - needs to be on the previous line

RFC 7230 sec 3.2.6 defines header values as potentially quoted strings, which
makes commas in header values unambiguous. It's also the only way to escape a
reserved character. This adds a test for list values with a comma and for list
values with escaped double quotes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants