-
Notifications
You must be signed in to change notification settings - Fork 8
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
the function is_legal_header_name should not allow any control character (octets 0 - 31) and DEL (127) #41
Comments
Hi, Thank you for the report. from requests import get
entries = [
'\x00',
'\x07',
'invalid"',
'invalid/'
]
for entry in entries:
r = get(
"https://httpbin.org/headers",
headers={
entry: "test"
}
)
print(
entry,
"KO" if r.status_code == 400 else "OK"
) KO = does not work and the remote server responds with 400/INVALID REQUEST
|
Further tests on the '/' indicate that this character is allowed anywhere, beginning, ending, multiple times. |
More: from kiss_headers import parse_it
from kiss_headers.utils import is_legal_header_name
from requests import get, post
if __name__ == "__main__":
entries = [
'invalid/',
'/invalid',
'/',
'//invalid/'
]
for entry in entries:
r = get(
"https://httpbin.org/headers",
headers={
entry: "test"
}
)
print(
entry,
"KO" if r.status_code == 400 else "OK",
f"is_legal_header_name({is_legal_header_name(entry)})"
) |
cf. PR #42
|
Remote server of httpgin.org is "gunicorn" which not always follow the original source (RFCs), One more thing, the "\x7f" maybe risky for commandline environment (terminal) such as logging to some kind of console. Anyway, what I cause this issue is only because of the RFC defined below:
which said separators or delimiters are excepted (the "/" is not allowed). |
We have to be flexible regarding the RFC. I did not say that httpbin was RFC compliant. For ref, look at encode/httpx#1363 + all related topics/issues on httpx deps. |
Describe this issue
The function is_legal_header_name @ against to the RFC2616 (RFC7230 ?)
about CTLs (octets 0 - 31 and DEL 127) and the 19 seprartors (\x2f, \x22)
or I am missing any udates of the RFCs.
ref:
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Stacktrace
If applicable, add stacktrace to help explain your problem.
Additional context
The text was updated successfully, but these errors were encountered: