Skip to content

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

Open

Description

@paulownia

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 '. 

Activity

  1. jeremyevans commented on Mar 24, 2025

    @jeremyevans
    Collaborator

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

  2. paulownia commented on Mar 25, 2025

    @paulownia
    ContributorAuthor

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

  3. jeremyevans commented on Mar 25, 2025

    @jeremyevans
    Collaborator

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions