Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Plus signs in CGI parameters mean spaces. That's in the CGI spec. Any HTTP client that sends you plus signs to mean anything else is broken. Any HTTP server that processes plus signs to mean anything else is broken.</p> <p>So the problem is not in your CGI program (which is doing the right thing). The problem is in the HTTP client which is sending you plus signs intending them to be interpreted as plus signs. The correct way to sent a plus sign as a parameter in a CGI program is to encode it as %2B. That's the problem that you need to fix.</p> <p><strong>Update:</strong> I've run a simple test using Apache on Ubuntu.</p> <p>My HTML file looked like this:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Test&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Test&lt;/h1&gt; &lt;form action="/cgi-bin/param"&gt; &lt;input name="some_field" value="1 + 1 is 2"&gt; &lt;input name="submit" type="submit" value="Submit"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>My Perl program looked like this:</p> <pre><code>#!/usr/bin/perl use strict; use warnings; use 5.010; use CGI qw[header param]; print header(-type =&gt; 'text/plain'); for (param) { say "$_ -&gt; ", join ':', param($_); } </code></pre> <p>When I visited the page and hit the 'submit' button, the browser went to the URL <code>http://localhost/cgi-bin/param?some_field=1+%2B+1+is+2&amp;submit=Submit</code> and displayed the following:</p> <pre><code>some_field -&gt; 1 + 1 is 2 submit -&gt; Submit </code></pre> <p>This looks like the behaviour I expect to see. The browser correctly encodes the plus sign to %2B when sending it to the browser. Perl's CGI module decodes that value when I access it.</p> <p>You need to track down why your browser (or whatever other client you're using to send these requests) isn't following the CGI spec.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload