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

CGI script using LF line breaks in headers causes error #165

Open
paulownia opened this issue Mar 24, 2025 · 3 comments · May be fixed by #166
Open

CGI script using LF line breaks in headers causes error #165

paulownia opened this issue Mar 24, 2025 · 3 comments · May be fixed by #166

Comments

@paulownia
Copy link
Contributor

The change introduced in #138 disallows bare LFs in headers and request lines. This change is good, but it also affects CGIHandler, causing scripts that use bare LF as a header separator to fail. However, according to RFC 3875, unlike HTTP, bare LFs are allowed in CGI header syntax.

For example, the following CGI script will fail when run under WEBrick 1.8 and later:

#!/usr/bin/ruby

print "Content-Type: text/html\n"
print "\n"
print "<html>example</html>"

In this case, the error message displayed in the browser is:

bad header 'Content-Type: text/html '. 
@jeremyevans
Copy link
Contributor

Thank you for the report. I agree this is a bug. I'll try to work on a fix this week.

@paulownia
Copy link
Contributor Author

Thanks! I'm preparing a fix as well. I'll submit a PR shortly. -- feel free to adjust or close it if needed.

@jeremyevans
Copy link
Contributor

I've you are already working on a fix, no point in duplicating effort. I'm happy to wait for your PR and will review it after it is submitted. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants