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

Allow digits and valid token chars in headers #134

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

jhnstrk
Copy link
Contributor

@jhnstrk jhnstrk commented Mar 24, 2024

The part header parsing has been extended to allow additional non-alpha characters that are allowed by the http spec.

In general http header field names can contain a variety of non-alpha characters, yet the present code only allows for a hyphen in addition to alphabetic characters. For multipart/form-data this may not be a a problem since additional headers are discouraged. For other multipart types, such as related and mixed, it may be an issue.

Since there was a test explicitly checking for failure with numbers in the header name, this seems to been an active choice. I altered this test to replace the numbers with characters forbidden by the spec.

The lower_char function was removed because it was no longer used.

@jhnstrk
Copy link
Contributor Author

jhnstrk commented Mar 24, 2024

This addresses #133

def lower_char(c: int) -> int:
return c | 0x20
# Mask for ASCII characters that can be http tokens.
# Per RFC7230 - 3.2.6, this is all alpha-numeric characters
Copy link
Owner

Choose a reason for hiding this comment

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

Can you add the link on the comment as well, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. I added a commit with the link.

@Kludex Kludex merged commit 3ea51c7 into Kludex:master Apr 18, 2024
6 checks passed
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.

2 participants