Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid regexp in perl -V #6806

Closed
p5pRT opened this issue Oct 1, 2003 · 14 comments
Closed

invalid regexp in perl -V #6806

p5pRT opened this issue Oct 1, 2003 · 14 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 1, 2003

Migrated from rt.perl.org#24081 (status was 'resolved')

Searchable as RT24081$

@p5pRT
Copy link
Author

p5pRT commented Oct 1, 2003

From Robin.Barker@npl.co.uk

Created by robin.barker@npl.co.uk

This is an issue with C<config_re> in Config.pm

% perl -V​:'?flags'
Surpring works and list all the .*flags config vars.

It works because the regexp used in config_re become
  /^?flags=/
so the ? (optionally) undoes the ^.

Is this a neat feature, or should the -V​:regexp only
accept valid regexps?

I have a patch for the latter case [attached].

Robin

Perl Info

Flags:
    category=library
    severity=low

Site configuration information for perl v5.8.1:

Configured by rmb1 at Thu Sep 25 13:55:06 BST 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 1) configuration:
  Platform:
    osname=solaris, osvers=2.7, archname=sun4-solaris-64int
    uname='sunos tempest 5.7 generic_106541-04 sun4u sparc
sunw,ultra-5_10 '
    config_args='-Dcc=/opt/gcc/bin/gcc -des -Dprefix=/opt/perl
-Dman1dir=none -Dman3dir=none -Uinstallusrbinperl -Doptimize=-O -g
-Duse64bitint -Dcf_email=rmb1@cise.npl.co.uk -Dcf_by=Robin Barker
-Dinc_version_list=5.8.0 5.6.1 5.6.0 5.005
-Dotherlibdirs=/usr/local/lib/perl5/site_perl'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='/opt/gcc/bin/gcc', ccflags ='-DDEBUGGING -fno-strict-aliasing
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O -g',
    cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='3.3', gccosandvers='solaris2.7'
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=87654321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8,
Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='/opt/gcc/bin/gcc', ldflags =' -L/usr/local/lib '
    libpth=/usr/local/lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldb -ldl -lm -lc
    perllibs=-lsocket -lnsl -ldl -lm -lc
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -Wl,-E
-z ignore -z lazyload -z combreloc'
    cccdlflags='-fPIC', lddlflags=' -Wl,-E -G -G  -z ignore -z lazyload
-z combreloc -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.8.1:
    /home/rmb1/appl/lib/perl5/5.8.1/sun4-solaris-64int
    /home/rmb1/appl/lib/perl5/5.8.1
    /home/rmb1/appl/lib/perl5/site_perl/5.8.1/sun4-solaris-64int
    /home/rmb1/appl/lib/perl5/site_perl/5.8.1
    /home/rmb1/appl/lib/perl5/site_perl/5.8.0
    /home/rmb1/appl/lib/perl5/site_perl/5.6.1
    /home/rmb1/appl/lib/perl5/site_perl/5.6.0
    /home/rmb1/appl/lib/perl5/site_perl/5.005
    /home/rmb1/appl/lib/perl5/site_perl
    /opt/perl/lib/5.8.1/sun4-solaris-64int
    /opt/perl/lib/5.8.1
    /opt/perl/lib/site_perl/5.8.1/sun4-solaris-64int
    /opt/perl/lib/site_perl/5.8.1
    /opt/perl/lib/site_perl/5.8.0
    /opt/perl/lib/site_perl/5.6.1
    /opt/perl/lib/site_perl/5.6.0
    /opt/perl/lib/site_perl/5.005
    /opt/perl/lib/site_perl
    /usr/local/lib/perl5/site_perl/5.8.0
    /usr/local/lib/perl5/site_perl/5.6.0
    /usr/local/lib/perl5/site_perl/5.005
    /usr/local/lib/perl5/site_perl
    .


Environment for perl v5.8.1:
    HOME=/home/rmb1
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/usr/lib
    LOGDIR (unset)
 
PATH=/home/rmb1/appl/script:/opt/SUNWspci/bin/:/usr/tempest/bin:/usr/loc
al/bin:/usr/local/Admigration/exec:/usr/local/hotjava/bin:/usr/openwin/b
in:/usr/dt/bin:/usr/ccs/bin:/usr/bin
 
PERL5LIB=/home/rmb1/appl/lib/perl5/5.8.1:/home/rmb1/appl/lib/perl5/site_
perl
    PERLDOC=-n 'groff -Tlatin1'
    PERL_BADLANG (unset)
    SHELL=/bin/tcsh



-------------------------------------------------------------------
This e-mail and any attachments may contain confidential and/or
privileged material; it is for the intended addressee(s) only.
If you are not a named addressee, you must not use, retain or
disclose such information.

NPL Management Ltd cannot guarantee that the e-mail or any
attachments are free from viruses.

NPL Management Ltd. Registered in England and Wales. No: 2937881
Registered Office: Teddington, Middlesex, United Kingdom TW11 0LW.
-------------------------------------------------------------------

@p5pRT
Copy link
Author

p5pRT commented Oct 1, 2003

From Robin.Barker@npl.co.uk

configre.gz

@p5pRT
Copy link
Author

p5pRT commented Oct 2, 2003

From @ysth

On Wed, 1 Oct 2003, Robin Barker wrote​:

% perl -V​:'?flags'
Surpring works and list all the .*flags config vars.

It works because the regexp used in config_re become
/^?flags=/
so the ? (optionally) undoes the ^.

Is this a neat feature, or should the -V​:regexp only
accept valid regexps?

I have a patch for the latter case [attached].

I think it would be sufficient for configpm to wrap a (?​: )
around it, and let whoever wants to foil it with something like
perl -V​:')|uv|(' go ahead and do so.

@p5pRT
Copy link
Author

p5pRT commented Oct 5, 2003

From @rgs

Yitzchak Scott-Thoennes wrote​:

On Wed, 1 Oct 2003, Robin Barker wrote​:

% perl -V​:'?flags'
Surpring works and list all the .*flags config vars.

It works because the regexp used in config_re become
/^?flags=/
so the ? (optionally) undoes the ^.

Is this a neat feature, or should the -V​:regexp only
accept valid regexps?

I have a patch for the latter case [attached].

I think it would be sufficient for configpm to wrap a (?​: )
around it, and let whoever wants to foil it with something like
perl -V​:')|uv|(' go ahead and do so.

Reminds me this old japh :
  perl '-V​:));print"Just another Perl hacker,\n";(('

@p5pRT
Copy link
Author

p5pRT commented Oct 6, 2003

From ams@wiw.org

(Just for the record​: I don't think anything needs to be changed here.)

-- ams

@p5pRT
Copy link
Author

p5pRT commented Oct 7, 2003

From @ysth

On Mon, Oct 06, 2003 at 10​:13​:39AM +0530, Abhijit Menon-Sen <ams@​wiw.org> wrote​:

(Just for the record​: I don't think anything needs to be changed here.)

-- ams

I think perl should complain about Robin Barker's original case​:

perl -V​:'?flags'

Not having actually submitted a patch of my own, I'd much rather see
his applied than nothing.

@p5pRT
Copy link
Author

p5pRT commented Jun 9, 2004

From Robin.Barker@npl.co.uk

In an attempt to close #24081, here is a simplified patch.

Robin

--- configpm.orig Sun Nov 16 17​:26​:58 2003
+++ configpm
@​@​ -329,7 +329,7 @​@​

sub config_re {
  my $re = shift;
- return map { chomp; $_ } grep /^$re=/, split /^/, $Config_SH;
+ return map { chomp; $_ } grep eval{ /^(?​:$re)=/ }, split /^/, $Config_SH;
}

sub config_vars {
--- lib/Config.t.orig Fri Mar 14 11​:50​:25 2003
+++ lib/Config.t
@​@​ -6,7 +6,7 @​@​
  require "./test.pl";
}

-plan tests => 36;
+plan tests => 37;

use_ok('Config');

@​@​ -77,10 +77,15 @​@​
my $out2 = $$out;
$out->clear;

+Config​::config_vars('?flags');
+my $out3 = $$out;
+$out->clear;
+
untie *STDOUT;

like($out1, qr/^cc='\Q$Config{cc}\E';/, "config_vars cc");
like($out2, qr/^d_bork='UNKNOWN';/, "config_vars d_bork is UNKNOWN");
+like($out3, qr/​: not found$/, "config_vars with invalid regexp");

# Read-only.


This e-mail and any attachments may contain confidential and/or
privileged material; it is for the intended addressee(s) only.
If you are not a named addressee, you must not use, retain or
disclose such information.

NPL Management Ltd cannot guarantee that the e-mail or any
attachments are free from viruses.

NPL Management Ltd. Registered in England and Wales. No​: 2937881
Registered Office​: Teddington, Middlesex, United Kingdom TW11 0LW.


@p5pRT
Copy link
Author

p5pRT commented Jun 9, 2004

From Robin.Barker@npl.co.uk

config_re.patch
--- configpm.orig	Sun Nov 16 17:26:58 2003
+++ configpm
@@ -329,7 +329,7 @@
 
 sub config_re {
     my $re = shift;
-    return map { chomp; $_ } grep /^$re=/, split /^/, $Config_SH;
+    return map { chomp; $_ } grep eval{ /^(?:$re)=/ }, split /^/, $Config_SH;
 }
 
 sub config_vars {
--- lib/Config.t.orig	Fri Mar 14 11:50:25 2003
+++ lib/Config.t
@@ -6,7 +6,7 @@
     require "./test.pl";
 }
 
-plan tests => 36;
+plan tests => 37;
 
 use_ok('Config');
 
@@ -77,10 +77,15 @@
 my $out2 = $$out;
 $out->clear;
 
+Config::config_vars('?flags'); 
+my $out3 = $$out;
+$out->clear;
+
 untie *STDOUT;
 
 like($out1, qr/^cc='\Q$Config{cc}\E';/, "config_vars cc");
 like($out2, qr/^d_bork='UNKNOWN';/, "config_vars d_bork is UNKNOWN");
+like($out3, qr/: not found$/, "config_vars with invalid regexp"); 
 
 # Read-only.
 

@p5pRT
Copy link
Author

p5pRT commented Jun 9, 2004

From @rgs

Robin Barker wrote​:

In an attempt to close #24081, here is a simplified patch.

Your patch (with the necessary adjustments) causes several regression
tests to fail on bleadperl, where the format of output has changed.
If you replace qr/​: not found$/ by qr/​: not found/ your new test
passes, but other tests fail for a reason I've not investigated.

--- configpm.orig Sun Nov 16 17​:26​:58 2003
+++ configpm
@​@​ -329,7 +329,7 @​@​

sub config_re {
my $re = shift;
- return map { chomp; $_ } grep /^$re=/, split /^/, $Config_SH;
+ return map { chomp; $_ } grep eval{ /^(?​:$re)=/ }, split /^/, $Config_SH;
}

sub config_vars {
--- lib/Config.t.orig Fri Mar 14 11​:50​:25 2003
+++ lib/Config.t
@​@​ -6,7 +6,7 @​@​
require "./test.pl";
}

-plan tests => 36;
+plan tests => 37;

use_ok('Config');

@​@​ -77,10 +77,15 @​@​
my $out2 = $$out;
$out->clear;

+Config​::config_vars('?flags');
+my $out3 = $$out;
+$out->clear;
+
untie *STDOUT;

like($out1, qr/^cc='\Q$Config{cc}\E';/, "config_vars cc");
like($out2, qr/^d_bork='UNKNOWN';/, "config_vars d_bork is UNKNOWN");
+like($out3, qr/​: not found$/, "config_vars with invalid regexp");

@p5pRT
Copy link
Author

p5pRT commented Jun 9, 2004

From @tamias

On Wed, Jun 09, 2004 at 12​:02​:01PM +0100, Robin Barker wrote​:

In an attempt to close #24081, here is a simplified patch.

Robin

--- configpm.orig Sun Nov 16 17​:26​:58 2003
+++ configpm

- return map { chomp; $_ } grep /^$re=/, split /^/, $Config_SH;
+ return map { chomp; $_ } grep eval{ /^(?​:$re)=/ }, split /^/, $Config_SH;

+like($out3, qr/​: not found$/, "config_vars with invalid regexp");

Is the intent that this regex throws an error in the eval, or just that it
doesn't match anything?

Ronald

@p5pRT
Copy link
Author

p5pRT commented Jun 9, 2004

From @rgs

Ronald J Kimball wrote​:

On Wed, Jun 09, 2004 at 12​:02​:01PM +0100, Robin Barker wrote​:

In an attempt to close #24081, here is a simplified patch.

Robin

--- configpm.orig Sun Nov 16 17​:26​:58 2003
+++ configpm

- return map { chomp; $_ } grep /^$re=/, split /^/, $Config_SH;
+ return map { chomp; $_ } grep eval{ /^(?​:$re)=/ }, split /^/, $Config_SH;

+like($out3, qr/​: not found$/, "config_vars with invalid regexp");

Is the intent that this regex throws an error in the eval, or just that it
doesn't match anything?

in this test that's actually /?flags/ used as an ivalid regexp, a few lines earlier.

$ perl -ce '/?flags/'
Quantifier follows nothing in regex; marked by <-- HERE in m/? <-- HERE flags/ at -e line 1.

@p5pRT
Copy link
Author

p5pRT commented Jun 9, 2004

From Robin.Barker@npl.co.uk

The intent is that
(1) invalid regexp in V​: do not become valid
  hence the (?​: ) round $re
(2) invalid regexp do not produce an error
  hence the eval
(3) invalid regexp do not match
  (function of C<grep eval>)

My earlier patch reverse the intent of (2)​: an invalid regexp
produced an intelligible error that was returned to the user.

The problems with doing something with the error from the eval
in the map expression are
(*) the error has lots of distracting context information
(*) the regexp in the error message includes the enclosing /^ =/
  which the user did not type.

Robin

-----Original Message-----
From​: Ronald J Kimball [mailto​:rjk-perl-p5p@​tamias.net]
Sent​: 09 June 2004 14​:37
To​: Robin Barker
Cc​: 'perl5-porters@​perl.org'
Subject​: Re​: [PATCH] Re​: [perl #24081] invalid regexp in perl -V

On Wed, Jun 09, 2004 at 12​:02​:01PM +0100, Robin Barker wrote​:

In an attempt to close #24081, here is a simplified patch.

Robin

--- configpm.orig Sun Nov 16 17​:26​:58 2003
+++ configpm

- return map { chomp; $_ } grep /^$re=/, split /^/, $Config_SH;
+ return map { chomp; $_ } grep eval{ /^(?​:$re)=/ }, split /^/, $Config_SH;

+like($out3, qr/​: not found$/, "config_vars with invalid regexp");

Is the intent that this regex throws an error in the eval, or just that it
doesn't match anything?

Ronald


This e-mail and any attachments may contain confidential and/or
privileged material; it is for the intended addressee(s) only.
If you are not a named addressee, you must not use, retain or
disclose such information.

NPL Management Ltd cannot guarantee that the e-mail or any
attachments are free from viruses.

NPL Management Ltd. Registered in England and Wales. No​: 2937881
Registered Office​: Teddington, Middlesex, United Kingdom TW11 0LW.


@p5pRT
Copy link
Author

p5pRT commented Jun 9, 2004

From @rgs

Robin Barker wrote​:

In an attempt to close #24081, here is a simplified patch.

Thanks, applied as #22921 with the further ajustments you made for
bleadperl.

@p5pRT
Copy link
Author

p5pRT commented Jun 9, 2004

@rgs - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant