Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>OK thank you for showing your complete code. The problem is that you are passing the contents of <code>$body</code> as a URL parameter, and so the HTTP protocl needs various characters escaping to pass them through properly.</p> <p>You can achieve this with the <a href="https://metacpan.org/module/URI%3a%3aEscape" rel="nofollow"><code>URI::Escape</code></a> module, and you will no longer have to do the sanitizing that you do on line 125 and the lines following <code># clean the body</code>.</p> <p>This program uses a string containing all the problem characters you have identified, and translates it using the module. If you use <code>uri_escape</code> on the contents of <code>$body</code> before appending it to the URL for Curl then everything should work.</p> <pre><code>use strict; use warnings; use URI::Escape 'uri_escape'; my $body = '%localappdata% â &amp; '; print uri_escape $body; </code></pre> <p><strong>output</strong></p> <pre><code>%25localappdata%25%20%E2%20%26%20 </code></pre> <hr> <p><strong>Update</strong></p> <p>For manipulating URLs in general it is best to use the <a href="https://metacpan.org/module/URI" rel="nofollow"><code>URI</code> module</a> which will do all necessary escaping for you in both the path and the query part of the URL.</p> <p>The program below shows how to generate the URL you need to pass to <code>$curl-&gt;setopt</code> using this method</p> <pre><code>use strict; use warnings; use URI; my $url = URI-&gt;new('https://this/is/the/url'); my $body = '%localappdata% â &amp; '; $url-&gt;query_form(body =&gt; $body); print $url, "\n"; </code></pre> <p><strong>output</strong></p> <pre><code>https://this/is/the/url?body=%25localappdata%25+%E2+%26+ </code></pre> <p>(Note that this method uses <code>+</code> instead of <code>%20</code> for space characters. Either is acceptable in the query portion of a URL.)</p> <p>This URL can be set as a Curl option directly by writing</p> <pre><code>$curl-&gt;setopt(CURLOPT_URL, $url); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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