-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
CGIHTTPRequestHandler.run_cgi() HTTP_ACCEPT improperly parsed #49304
Comments
There appears to have been a bug in how HTTP_ACCEPT is parsed living in From Line 980 of http.server accept = []
for line in self.headers.getallmatchingheaders('accept'):
if line[:1] in "\t\n\r ":
accept.append(line.strip())
else:
accept = accept + line[7:].split(',')
env['HTTP_ACCEPT'] = ','.join(accept) line[:1] in '\t\n\r' clearly was meant to to be line[-1]. However that doesn't fix completely this chunk of code as it makes some accept = []
for line in self.headers.getallmatchingheaders('accept'):
if line.lower().startswith("accept:"):
line = line[7:]
for part in line.split(','):
part = part.strip()
if part:
accept.append(part)
env['HTTP_ACCEPT'] = ','.join(accept) Note that post Python 3.0 release, |
I hope that someone who knows more than me on this subject takes a look at this. |
Posting a patch for this so that we can get rid of the broken HTTPMessage.getallmatchingheaders() method in bpo-5053. |
BTW in the original code, I think line[:1] in "\t\n\r " might have been correct. It looks like the getallmatchinheaders() method was actually meant to return continued lines separately, prefixed with whitespace. My patch is probably only appropriate for Python 3; maybe Mike’s code will work for Python 2. |
This was also resolved in 3.10 #23638 |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: