Search code examples
lwpnewlinelwp-useragent

LWP::UserAgent 6.04, POST and new behavior in \n as a part of the content


After an upgrade to LWP 6.04 from an older (5.8x?) version, i noticed that some code used in a distributed app that ran forever started breaking. I traced it to the change in handling of the \n in a POST.

On the client:

    $post_data{'good'} = qq(This is a text line);
    $post_data{'bad'} = qq(This is a first line\nThis is a second line);

    my $ua = LWP::UserAgent->new();
    my $response = $ua->post( $url, \%post_data );
    return undef if (!defined $response);

On the server:

    my $good = $q->param('good');
    my $bad = $q->param('bad');

After the client runs server gets the following:

$good on the server side as expected ends up being qq(This is a text line). $bad, however, ends up being qq(This is a first line\r\nThis is a second line).

Is there a way to avoid this "helpful" substitution without rewriting and redeploying the massive amount of code that utilized the previous behavior of LWP::UserAgent?


Solution

  • https://rt.cpan.org/Public/Bug/Display.html?id=75592