Preserve plus signs from CGI input in Perl -


I am working on a web application with a number of variables on which the user is expected to input data, in which often empty Location and / or plus sign

The data is usually sent through the GET requests; Or application / x-www-form-urlencoded content-type header

with either POST Code> Vars () and param from the CGI module of Pearl, but change the signals in both of these methods in + Insist on

What is the CGI module + provides any mechanism to preserve signals; Or I should manually parse CGI and password input

note :
Large amounts of forms (More than a hundred), and being a CGI pre-processing in a central utility library, I am very biased towards server-side solutions rather than a client-side approach (in other words, I deal with it)

Thanks in advance for any help.

Examples : As a request in the comment, here is a (simplified) sample of some code that triggers this issue.

HTML

  form action = "/ cgi-bin / some -script.pl">     

Pearl

  Use CGI; my $ some_variable = CGI :: param ('some_field');   

form with default values After typing and running server-side code, the value of $ some_variable is "1 is 2" (There are three locations between 1, either site or Browser may be covered in one place) ; The desired result is to get value "1 + 2 2" in that value. Plus sign means the empty space in CGI parameters, it is in the CGI spec, any HTTP client that sends you more signals, this means that some Also, there is no problem in your CGI program (which is doing the right thing). The problem is in the HTTP client who is sending you more signals, which is more than that. To interpret as a sign The correct way to send a plus sign as a parameter in the CGI program is to encode it as a% 2B

Update: On Ubuntu Using Apache has run a simple test.

My HTML file looks like this:

   gt; Top & gt; & Lt; title & gt; Test & lt; / title & gt; & lt; / head & gt; Body & gt; & lt; h1 & gt; Test & lt; / h1 & gt; & lt; Form action = "/ cgi-bin / param" & gt; & lt; input name = "some_field" value = "1 + 1 2 "" gt; & lt; input name = "submit" type = "submit" value = "submit" & gt; & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

My Perl program looks like this:

  #! / Usr / bin / perl strict; Use warnings; Use 5.010; Use CGI Qi [Header param]; Print header (-type = & gt; 'text / plain'); ("$ _ - & gt;" says, ':', the ultimate ($ _);}   

When I visited the page and clicked the 'Submit' button If pressed, then the browser URL http: // localhost / cgi-bin / param? Some_field = 1 +% 2B + 1 + is +2 and submit = submit and is displayed below: < / P>

  some_field -> 1 + 1 is 2 submit -> submit >>   

I think that looks like the behavior of watching. When sending a browser, the browser correctly encodes the plus sign on% 2B. The CGI module decodes the value when I access it.

You need to know that your browser (or other customers you are using to send these requests ) CGI is not following the speck.

Comments