Skip to content

Commit

Permalink
normalize newlines in forms to CRLF
Browse files Browse the repository at this point in the history
HTTP::Message < 7.00 normalized newlines in requests to CRLF. This has
been removed. Based on the [HTML
spec](https://html.spec.whatwg.org/#converting-an-entry-list-to-a-list-of-name-value-pairs)
and [URL spec](https://url.spec.whatwg.org/#urlencoded-serializing), the CRLF
normalization should be in the HTML layer. So the change in
HTTP::Message is correct, and HTML::Form should be handling the
normalization.

Add normalization of lone \r or \n into \r\n, as defined in the HTML
spec.

Older HTTP::Message versions will do their own normalization. That
will end up being a no-op, so we will still be compatible with those
older versions.
  • Loading branch information
haarg committed Oct 17, 2024
1 parent cf9ebcc commit 63bf67a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Change history for HTML-Form

{{$NEXT}}
- Fix CRLF normalization with HTTP::Message 7.00

6.11 2023-02-11 11:49:19Z
- Perl::Tidy-ed the entire codebase (GH#42) (Julien Fiegehenn)
Expand Down
2 changes: 2 additions & 0 deletions lib/HTML/Form/Input.pm
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ sub form_name_value {
return if $self->disabled;
my $value = $self->value;
return unless defined $value;
s/\x0d?\x0a|\x0d/\x0d\x0a/g
for $name, $value;
return ( $name => $value );
}

Expand Down

0 comments on commit 63bf67a

Please sign in to comment.