Namaste, dear Perl Monks and Nuns!

I have a little site to administrate that depends on Perl scripts printing HTML and JavaScript. The site stores data in and loads data from a database using SOAP::Lite and up until last week everything ran very smoothly. Unfortunately our servers got an update that raised Perl from version 5.10.1 to 5.16.3 and there the problems started. Firstly all special characters, like ä, ö, ü, ß and € got mangled by the encoding. This error was resolved by using

use open qw(:std :utf8); use Encode; use utf8;

to load the data, by writing

print header(-type=>'text/html',-charset=>'utf-8'); print start_html(-title => "FooBar");

to start the web page and by using

my $text=decode("utf8", $query->param("textbox"));

to get the data back from the page and store it in the DB.

Today I had to realize that it's also no longer possible to load strings from the database that contain double quotes, because the HTML textboxes see the double quote as an end marker for the textbox value. (EDIT: Saving content with double quotes is possible. I verified this directly on database level.)

There are probably even a few more characters that cause issues that I haven't stumbled upon yet.

I found that I can resolve the issue by using HTML::Entities and calling encode_entities() on the variable I want to see in my textbox, but I am loading hundreds of variables and several arrays of strings in one page visit and there is no way I can revisit every single script in my application to see which variables I maybe need to encode.

Is there any way I can encode the whole HTML part of my script or a way to circumvent this mess?

Thanks alot in advance


In reply to Escaping double quotes in complete document by MeinName

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.