Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

perl5i + CGI::Simple makes warnings #163

Open
tokuhirom opened this Issue · 7 comments

4 participants

@tokuhirom
  % perl5i -E 'use CGI::Simple; say CGI::Simple->VERSION'
  utf8 "\xF1" does not map to Unicode at /usr/local/app/perl-5.12.1/lib/site_perl/5.12.1/CGI/Simple.pm line 474.
  1.112

perl5i output warnings when require module contains non-utf8 chars.

more pointed code is following:

% perl -e 'print "package F;\n # \xF1\n;1;"' > x.pl
% perl5i -e 'require "x.pl"'
utf8 "\xF1" does not map to Unicode at x.pl line 1.

This code is not output warnings with plain perl5 interpreter.

% perl -e 'require "x.pl"'
@schwern
Owner

There is a non-UTF8 character in there, but its in a comment way far away (España).

Anyhow, perl -wle 'use utf8; use warnings; use CGI::Simple doesn't provoke the warning. It shouldn't, utf8 should be lexical. Something perl5i is doing is letting it out of its box.

Valid bug.

@doherty

And now it is utf8::all that's doing something wrong.

@doherty doherty referenced this issue from a commit in doherty/utf8-all
@doherty doherty Use :utf8 PerlIO layer instead of :encoding(UTF-8)
This is the non-strict version of the encoding, which silences
the warnings reported in evalEmpire/perl5i#163 and doherty/utfu-all#5
221e994
@Leont

The bug is not in utf8::all but in perl itself. It seems require is affected by the open pragma, as can be seen in this example:

perl '-Mopen=:encoding(utf8)' -e 'require "x.pl"'

I'm not sure how to solve this (other than in perl 5.15.x)

@doherty

This was discussed at some point on p5p. I meant to ask if there was a workaround older Perls could use, but I don't think I ever did. I should check who was talking about this and get in touch with them about it.

@doherty doherty referenced this issue in doherty/utf8-all
Closed

utf8::all is doing something un-lexical #5

@schwern
Owner
@doherty

Yes, using the :utf8 layer would work - however it's both the wrong way to solve the issue and also unsafe. I think the Perl bug was fixed, but I'm not sure if it was (or even can be) fixed in older Perls somehow. I'm open to advice on whether the hacky thing is the right way to do it.

@Leont

The bug was fixed in core in 639dfab029, but that doesn't help users of perl < 5.15. You could do some trick with an OP check function, but I'm not sure that's worth it. Doing :utf8 is probably even be more undesirable though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.