[cgiapp] encoding pragma and CGI::Session

Todd Ross tar.lists at yahoo.com
Tue Sep 28 14:17:24 EDT 2010


Hi Mark,

Honestly, I'm a little fuzzy on the details or history of this particular 
program.  I believe that we added the use encoding 'utf8' as an attempt to 
support international characters in a form submission.  Upon closer examination 
of this program, there's actually an edit in place to prevent the submission of 
non-US7ASCII characters.  So, it looks like we gave up trying to solve the 
problem and the use encoding 'utf8' is just leftover.  We're probably going to 
end up removing it as we want CGI::Session more than a half-baked UTF8 
implementation.

We aren't even trying to store UTF8 data in the session.  The mere presence of 
the pragma breaks CGI::Session.

I have seen/read that wikibooks.org link.  If we revisit this topic, that's 
probably the document we'll be referring to.  When I finally isolated the source 
of the compatibility problem, I came to the same conclusion as you; use encoding 
'utf8' is meant to address the encoding of the source code, not the data, and 
that it wasn't addressing the problem we were originally trying to solve.

Todd




________________________________
From: Mark Rajcok <mrajcok at gmail.com>
To: CGI Application <cgiapp at lists.openlib.org>
Sent: Mon, September 27, 2010 10:37:15 PM
Subject: Re: [cgiapp] encoding pragma and CGI::Session

On Fri, Sep 3, 2010 at 8:31 PM, Ron Savage <ron at savage.net.au> wrote:

> Hi Todd
> Thanx for the sample code.
> More below.
>
> On Fri, 2010-09-03 at 09:08 -0700, Todd Ross wrote:
> > CGI::Session: 4.20
>
> Firstly, you can get V 4.42 from CPAN and V 4.45 from the repository.
> But, most importantly, I put a discussion of UTF8 in the docs:
>
>
>http://search.cpan.org/~markstos/CGI-Session-4.42/lib/CGI/Session.pm#A_Warning_about_UTF8<http://search.cpan.org/%7Emarkstos/CGI-Session-4.42/lib/CGI/Session.pm#A_Warning_about_UTF8>
>>
>

Following the link I read this statement "Until this problem is understood
and corrected, users are advised to avoid UTF8 in conjunction with
CGI::Session".  Yikes!  Is it really that bad?  I'm using UTF-8 (everywhere
in my app) with CAP::Session without any problems  (although with a MySQL
backend for session storage, I did have to change the a_session field to a
"blob").

Todd, what was your intent with the   use encoding 'utf8';  line?  Do you
only want to save and restore UTF-8 encoded session data?  or do you want to
do that PLUS have Perl consider your script (i.e., file test.pl) to be
encoded in UTF-8?  I ask because I find this to be a common misunderstanding
about UTF-8.  The 'use encoding...' line is usually not what people should
use.  If you only want the script to read/write UTF-8, and your script is in
normal ASCII/ISO-8859-1 encoding, then try this instead of the 'use
encoding..' line to get the script to read and write UTF-8 on stdin and
stdout:
  binmode STDIN, ":encoding(utf8)";
  binmode STDOUT, ":encoding(utf8)";

With the above two lines, your script worked for me.

This might help: http://en.wikibooks.org/wiki/Perl_Programming/Unicode_UTF-8
(something I wrote a while ago when trying to understand how UTF-8 works).

-- Mark


> See also the discussions on RT:
> https://rt.cpan.org/Public/Bug/Display.html?id=21981
> https://rt.cpan.org/Public/Bug/Display.html?id=28516
> Naturally, if can help us resolve this problem, we'd all be delighted.
>
> --
> Ron Savage
>
>

#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://lists.openlib.org/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:  http://lists.openlib.org/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


      


More information about the cgiapp mailing list