Skip Menu |

This queue is for tickets about the Tk CPAN distribution.

Report information
The Basics
Id: 41068
Status: resolved
Priority: 0/
Queue: Tk

People
Owner: Nobody in particular
Requestors: krasnoroot [...] mail.ru
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Tk::FBox bug report
Date: Thu, 20 Nov 2008 00:27:25 +0500
To: bug-Tk [...] rt.cpan.org
From: Alexander Krasnorutsky <krasnoroot [...] mail.ru>

Message body is not shown because sender requested not to inline it.

Hello! I think that there is an error in the Tk::FBox module (VERSION 4.019; Tk 804.028). 1) If user enters expression like '?????' he will see this error message: XS_Tk__Callback_Call error:Nested quantifiers in regex;marked by <-- HERE in m/^??? <-- HERE ??$/ at /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi/Tk/FBox.pm line 1041. 2) If filename contains a newline character (it is possible on ext2/ext3) then this file will be invisible in the icon list. 3) Multiple globs work wrong (i.e., filenames matching /^regex/ or /regex/ or /regex$/ will be shown but not only ones which match /^regex$/). I think (IMHO) that 1),2),3) are because of an error at "_rx_to_glob" subroutine. 4) "perlvar" says about $] : 'When testing the variable, to steer clear of floating point inaccuracies you might want to prefer the inequality tests "<" and ">" to the tests containing equivalence: "<=", "==", and ">="'. I have written a patch: # patchFBox_BasicGlob.diff; compatible with tkfbox.tcl ========= cut here ========= 454c454 < next if !-d $f && $f !~ m!$flt!; --- Show quoted text
> next if !-d $f && $f !~ m!$flt!s;
560c560 < if (!-d $path && $path !~ /\..+$/ && defined $defaultext) { --- Show quoted text
> if (!-d $path && $path !~ /\..+$/s && defined $defaultext) {
995c995 < } elsif ($dir =~ m|^~/(.*)|) { --- Show quoted text
> } elsif ($dir =~ m|^~/(.*)|s) {
997c997 < } elsif ($dir =~ m|^~([^/]+(.*))|) { --- Show quoted text
> } elsif ($dir =~ m|^~([^/]+(.*))|s) {
1036,1041c1036,1040 < $arg = join('|', split(' ', $arg)); < $arg =~ s!([\.\+])!\\$1!g; < $arg =~ s!\*!.*!g; < $arg = "^" . $arg . "\$"; < if ($] >= 5.005) { < $arg = qr/$arg/; --- Show quoted text
> $arg =~ s!([.+^()|\@\${}\[\]\\])!\\$1!g; > $arg = join('|', map {"^$_\\z"} split(' ', $arg)); > $arg =~ s!\*!.*!g;$arg =~ s!\?!.!g; > if ($] > 5.0049) { > $arg = qr/$arg/s;
========= cut here ========= . This patch is also available as an attachment to this message. It also would be nice to provide a method (for programmers who use this module) to specify custom encodings for displaying filenames (not only Latin-1). Best regards -- Alexander Krasnorutsky.
CC: undisclosed-recipients: ;
Subject: Re: [rt.cpan.org #41068] Tk::FBox bug report
Date: Wed, 19 Nov 2008 13:14:32 -0800
To: Alexander Krasnorutsky via RT <bug-Tk [...] rt.cpan.org>
From: Ilya Zakharevich <nospam-abuse [...] ilyaz.org>
On Wed, Nov 19, 2008 at 02:28:22PM -0500, Alexander Krasnorutsky via RT wrote: Show quoted text
> 4) "perlvar" says about $] : > 'When testing the variable, to steer clear of floating point > inaccuracies you might want to prefer the inequality tests "<" > and ">" to the tests containing equivalence: "<=", "==", and ">="'.
I do not think this makes any sense. When $] is compared against a numeric literal, rounding should not matter. If I'm wrong, please show me how... Show quoted text
> < if ($] >= 5.005) {
The intent here is very clear. Show quoted text
> > if ($] > 5.0049) {
I would have no idea what the writer of this wanted to express. Hope this helps, Ilya P.S. Do not use `diff' when creating a patch. Please use `diff -c', or (IMO, preferably) `diff -pu'.
Subject: Re: [rt.cpan.org #41068] Tk::FBox bug report
Date: Mon, 24 Nov 2008 19:27:28 +0500
To: bug-Tk [...] rt.cpan.org
From: Alexander Krasnorutsky <krasnoroot [...] mail.ru>

Message body is not shown because sender requested not to inline it.

On Wed, 2008-11-19 at 16:15 -0500, Ilya Zakharevich via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=41068 > > > On Wed, Nov 19, 2008 at 02:28:22PM -0500, Alexander Krasnorutsky via RT wrote:
> > 4) "perlvar" says about $] : > > 'When testing the variable, to steer clear of floating point > > inaccuracies you might want to prefer the inequality tests "<" > > and ">" to the tests containing equivalence: "<=", "==", and ">="'.
> > I do not think this makes any sense. > > When $] is compared against a numeric literal, rounding should not > matter. If I'm wrong, please show me how... >
> > < if ($] >= 5.005) {
> > The intent here is very clear. >
> > > if ($] > 5.0049) {
> > I would have no idea what the writer of this wanted to express. > > Hope this helps, > Ilya > > P.S. Do not use `diff' when creating a patch. Please use `diff -c', > or (IMO, preferably) `diff -pu'. >
Ilya Zakharevich is right, the first version of this line (with ">=" comparison) is clear and it works fine. But if somebody have localised $], made some arithmetic operations with it (and resulting value is "equal" to the old one, but not exactly the same because of floating point inaccuracies) then ">=" comparison will (maybe) tell that the new value is "less than" the old ("true") one. However, writing "local $] = ..." is not a good style (programmer should take into account this inaccuracies) and it is difficult to imagine why it may be needed, so I agree with Ilya. It is not needed to paste a backslash before "@" in $arg because arrays will not interpolate ($arg has already been interpolated as a variable), it is my silly mistake. Here is my corrected patch (with `diff -pu'): # patchFBox_Glob.diff ======================================= --- FBox_orig.pm 2008-11-11 20:30:38.000000000 +0500 +++ FBox.pm 2008-11-24 18:26:21.000000000 +0500 @@ -451,7 +451,7 @@ sub Update { if ($fltcb) { next if !$fltcb->($w, $f, $cwd); } else { - next if !-d $f && $f !~ m!$flt!; + next if !-d $f && $f !~ m!$flt!s; } if (-d $f) { $icons->Add($folder, $f); @@ -557,7 +557,7 @@ sub ResolveFile { # If the file has no extension, append the default. Be careful not # to do this for directories, otherwise typing a dirname in the box # will give back "dirname.extension" instead of trying to change dir. - if (!-d $path && $path !~ /\..+$/ && defined $defaultext) { + if (!-d $path && $path !~ /\..+$/s && defined $defaultext) { $path = "$path$defaultext"; } # Cannot just test for existance here as non-existing files are @@ -992,9 +992,9 @@ sub ext_chdir { my $dir = shift; if ($dir eq '~') { chdir _get_homedir(); - } elsif ($dir =~ m|^~/(.*)|) { + } elsif ($dir =~ m|^~/(.*)|s) { chdir _get_homedir() . "/" . $1; - } elsif ($dir =~ m|^~([^/]+(.*))|) { + } elsif ($dir =~ m|^~([^/]+(.*))|s) { chdir _get_homedir($1) . $2; } else { chdir $dir; @@ -1033,12 +1033,11 @@ sub _untaint { sub _rx_to_glob { my $arg = shift; - $arg = join('|', split(' ', $arg)); - $arg =~ s!([\.\+])!\\$1!g; - $arg =~ s!\*!.*!g; - $arg = "^" . $arg . "\$"; + $arg =~ s!([.+^()|\${}\[\]\\])!\\$1!g; + $arg = join('|', map {"^$_\\z"} split(' ', $arg)); + $arg =~ s!\*!.*!g;$arg =~ s!\?!.!g; if ($] >= 5.005) { - $arg = qr/$arg/; + $arg = qr/$arg/s; } $arg; } ======================================= Best regards -- Alexander Krasnorutsky.
Subject: Re: [rt.cpan.org #41068] Tk::FBox bug report
Date: Wed, 26 Nov 2008 23:33:26 +0500
To: bug-Tk [...] rt.cpan.org
From: Alexander Krasnorutsky <krasnoroot [...] mail.ru>
Hello! A little notice: "perl5005delta" tell us that prior to perl 5.005 the maximum length of compiled regular expression was 32767. So it is needed to check the length of user input (though it is very unlikely that user will enter such a big string), otherwise this fatal error will be occurred: "regexp too big". Also, prior to perl 5.005 the "\z" regexp escape character was not available, so it is better to use "(?!\n)$" instead of it in my patch. However, Tk 804 is not compatible with pre-5.8.0 perl releases, so if we won't provide a patch for old Tk releases we can omit version check ("if ($] >= 5.005)") at all. Best regards -- Alexander Krasnorutsky.
On Thu Dec 04 14:11:35 2008, krasnoroot@mail.ru wrote: Show quoted text
> Hello! > A little notice: "perl5005delta" tell us that prior to perl 5.005 the > maximum length of compiled regular expression was 32767. So it is needed > to check the length of user input (though it is very unlikely that user > will enter such a big string), otherwise this fatal error will be > occurred: "regexp too big". > Also, prior to perl 5.005 the "\z" regexp escape character was not > available, so it is better to use "(?!\n)$" instead of it in my patch. > > However, Tk 804 is not compatible with pre-5.8.0 perl releases, so if we > won't provide a patch for old Tk releases we can omit version check ("if > ($] >= 5.005)") at all.
Indeed, the next version of Tk::FBox will have a "use 5.005;" on top. Regards, Slaven
(Modified) patch applied as change 12172 in the Tk SVN repository (https://svn.perl.org/modules/Tk/trunk). Thanks, Slaven