libwww-perl / libwww-perl/HTTP-Message

Escape quotes and backslashes HTTP::Request::Common [rt.cpan.org #51492]

Open
#66 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Perl
Stars
32
Forks
63
Avg merge
5h 14m
Merged PRs (30d)
1

Description

Migrated from rt.cpan.org#51492 (status was 'open')

Requestors:

  • jschulz.cpan@bloonix.de

From jschulz.cpan@bloonix.de on 2009-11-13 09:16:08:

Hi,

on line 126 of HTTP::Request::Common:

$k =~ s/([\\\"])/\\$1/g;  # escape quotes and backslashes

for some reasons I want to disable escaping of quotes.

Is that possible? Maybe with a global variable like

$HTTP::Request::Common::ESCAPEQUOTES=0;

Cheers,
Jonny

From reed@reedloden.com on 2009-12-01 08:35:51:

From my duplicate ticket #52312, here's a reason why people would want
to not have backslashes escaped:

I'm using LWP::UserAgent to send requests to a custom server-side
service. LWP::UserAgent uses HTTP::Request internally, which uses
HTTP::Request::Common to process requests. HTTP::Request::Common has a
line of code that makes sending plain '\n' in requests just not possible:
$k =~ s/([\\\"])/\\$1/g; # escape quotes and backslashes

I want to be able to send "\n" in a form value, but I can't because of
the above line. This means that even if I have a parameter "paths" with
"/img/blah.png\n/img/blah2.png", HTTP::Request::Common happily converts
the '\n' to '\\n', changing "paths" to be "/img/blah.png\\n/img/blah2.png".

I think I should be able to send "\n" in a form value.

I can write a small test script if it's needed...

From jschulz.cpan@bloonix.de on 2009-12-01 09:47:23:

Okay, then some words about my concern.

My reason is that I send a post request to a HTTP-Server (ticket 
system). The data within the post request are used to generate a email. 
If the text contains quotation marks

Foo bar "foo baz" foo bar.

then the mail text contains backslashes

Foo bar \"foo baz\" foo bar.

for this reason I want to disable quoting.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read HTTP::Request::Common around line 126 and trace how form values become the request body. Reproduce the quoted and newline-containing values from the report, then inspect existing tests for this path. Done means the request preserves the intended form value without unwanted escaping and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
perl
Domain
backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.