Skip Menu |
 

This queue is for tickets about the Config-Auto CPAN distribution.

Report information
The Basics
Id: 28608
Status: resolved
Priority: 0/
Queue: Config-Auto

People
Owner: Nobody in particular
Requestors: mike [...] perusion.com
Cc:
AdminCc:

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



Subject: Quoted parameters in Config::Auto
Date: Wed, 1 Aug 2007 07:14:46 -0400
To: bug-config-auto [...] rt.cpan.org
From: Mike Heins <mike [...] perusion.com>
Download (untitled) / with headers
text/plain 2.1k
When running Config::Auto on a file such as: set foo "bar, baby" You get: set => [ 'foo "bar', 'baby"', ], I believe that it should return: set => [ 'foo', 'bar, baby', ], This is of course my opinion, but I don't see how it would be useful otherwise. Two other things stand out: * Problems if tabs are used without a space character. * Problems if commas are in anything with quoting Here is a patch that fixes these things, using a core Perl module: --- /tmp/Config/Auto.pm.orig 2007-08-01 07:06:36.000000000 -0400 +++ /tmp/Config/Auto.pm 2007-08-01 07:11:00.000000000 -0400 @@ -1,9 +1,12 @@ package Config::Auto; +print "use me, baby!\n"; + use strict; use warnings; use File::Spec::Functions; use File::Basename; +use Text::ParseWords; #use XML::Simple; # this is now optional use Config::IniFiles; use Carp; @@ -282,7 +285,6 @@ } } - sub equal_sep { my $file = shift; open my $in, $file or die $!; @@ -292,10 +294,10 @@ /^\s*(.*?)\s*=\s*(.*)\s*$/ or next; my ($k, $v) = ($1, $2); my @v; - if ($v=~ /,/) { + if ($v=~ /,/ and $v !~ /(["']).*?,.*?\1/) { $config{$k} = [ split /\s*,\s*/, $v ]; - } elsif ($v =~ / /) { # XXX: Foo = "Bar baz" - $config{$k} = [ split /\s+/, $v ]; + } elsif ($v =~ /\s/) { # XXX: Foo = "Bar baz" + $config{$k} = [ shellwords($v) ]; } else { $config{$k} = $v; } @@ -313,10 +315,10 @@ /\s*(\S+)\s+(.*)/ or next; my ($k, $v) = ($1, $2); my @v; - if ($v=~ /,/) { + if ($v=~ /,/ and $v !~ /(["']).*?,.*?\1/) { @v = split /\s*,\s*/, $v; - } elsif ($v =~ / /) { # XXX: Foo = "Bar baz" - @v = split /\s+/, $v; + } elsif ($v =~ /\s/) { # XXX: Foo = "Bar baz" + $config{$k} = [ shellwords($v) ]; } else { @v = $v; } -- Mike Heins Perusion -- Expert Interchange Consulting http://www.perusion.com/ phone +1.765.647.1295 tollfree 800-949-1889 <mike@perusion.com> {((>:o}~ <<<<Oh look!!! An idolatrous image of the prophet!!! Surely we must now avenge this blasphemy by burning down the world!!!
Download (untitled) / with headers
text/plain 143b
On Wed Aug 01 07:15:56 2007, mike@perusion.com wrote: Show quoted text
> Here is a patch that fixes these things, using a core Perl module:
Thanks, applied :)


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.