undocumented tainting of variables with UTF8

Colin Tuckley <[email protected]> Thu, 08 Jun 2006 08:34:00 +0100
Newsgroups gmane.comp.lang.perl.tk
Message-ID <[email protected]>
This bug was reported against the Debian package of Perl-Tk. Does anyone
have any comments and/or suggestions for a solution?

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=362002

Package: perl-tk
Version: 1:804.027-4
Severity: normal


Tk::Entry fields (at least) change strings that are bound to them to
UTF8 strings (even if there's only 7bit characters in the strings).
That means that anything that is concatenated with such strings
becomes UTF8 automatically.

Now, if those strings happen to be filenames which contain latin1 (or
other non-UTF8, non-ascii) characters, when they get used by perl
(e.g. with "system", or "-d $filename"), they are converted to UTF8
and therefore no longer match the filenames on disk.

code to reproduce:

#!/usr/bin/perl -w
use strict;
use Tk;

my $fn = "te\xDFt"; # &szlig;
my $curdir = ".";
my $fullfn;
my $mw = MainWindow->new;

open F, ">$fn"; close F;
warn "touched $fn\n"; warnutf($fn);

$fullfn = "$curdir/$fn";
warn "$fullfn exists\n" if -e $fullfn;
warnutf($fullfn);

$mw->Entry(-textvariable => \$curdir);

warn "bound curdir to Entry\n";
$fullfn = "$curdir/$fn";
warn "$fullfn doesn't exist\n" unless -e $fullfn;
warnutf($fullfn);

sub warnutf {
    my $s = shift;
    warn "String is UTF-8\n" if utf8::is_utf8($s);
}

- - - - - - - - - - - - - - - - - - - - - - - - - - - -

Is this actually a bug?

regards,

Colin


-- 
Colin Tuckley      |  [email protected]  |  PGP/GnuPG Key Id
+44(0)1903 236872  |  +44(0)7799 143369  |     0x1B3045CE

"Apple" (c) Copyright 1767, Sir Isaac Newton.
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to [email protected]