Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make single-character header field names work again
header fields (so that multiline fields containing : were not identified
as a different fields) but inadvertently broke single-character fields.

Bug reported by bc547 on IRC.
  • Loading branch information
amenonsen committed Jun 8, 2014
1 parent ba4d20b commit 7ddef73
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes
@@ -1,5 +1,6 @@

5.05 2014-06-07
- Fixed parsing of header fields with single-character names.

5.04 2014-06-03
- Added expect_close attribute to Mojo::Content.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Headers.pm
Expand Up @@ -95,7 +95,7 @@ sub parse {
}

# New header
if ($line =~ /^(\S[^:]+)\s*:\s*(.*)$/) { push @$headers, $1, [$2] }
if ($line =~ /^(\S[^:]*)\s*:\s*(.*)$/) { push @$headers, $1, [$2] }

# Multiline
elsif (@$headers && $line =~ s/^\s+//) { push @{$headers->[-1]}, $line }
Expand Down
2 changes: 2 additions & 0 deletions t/mojo/headers.t
Expand Up @@ -133,6 +133,7 @@ is $headers->header('X-Test'), "23 24, single line, 25 26", 'right format';
$headers = Mojo::Headers->new;
isa_ok $headers->parse(<<'EOF'), 'Mojo::Headers', 'right return value';
Content-Type: text/plain
o: x
Expect: 100-continue
Cache-control: public
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Expand All @@ -143,6 +144,7 @@ is $headers->content_type, 'text/plain', 'right value';
is $headers->expect, '100-continue', 'right value';
is $headers->cache_control, 'public', 'right value';
is $headers->expires, 'Thu, 01 Dec 1994 16:00:00 GMT', 'right value';
is $headers->header('o'), 'x', 'right value';

# Parse multiline headers
$headers = Mojo::Headers->new;
Expand Down

0 comments on commit 7ddef73

Please sign in to comment.