Skip to content

Commit 90132a6

Browse files
haargoalders
authored andcommitted
normalize newlines in forms to CRLF
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.
1 parent af31026 commit 90132a6

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

Changes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Change history for HTML-Form
22

33
{{$NEXT}}
4+
- Fix CRLF normalization with HTTP::Message 7.00
45

56
6.11 2023-02-11 11:49:19Z
67
- Perl::Tidy-ed the entire codebase (GH#42) (Julien Fiegehenn)

lib/HTML/Form/Input.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ sub form_name_value {
113113
return if $self->disabled;
114114
my $value = $self->value;
115115
return unless defined $value;
116+
s/\x0d?\x0a|\x0d/\x0d\x0a/g
117+
for $name, $value;
116118
return ( $name => $value );
117119
}
118120

0 commit comments

Comments
 (0)