Skip Menu |

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

Report information
The Basics
Id: 64169
Status: resolved
Priority: 0/
Queue: Config-General

People
Owner: Nobody in particular
Requestors: fabrice [...] dulaunoy.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 2.48
  • 2.49
  • 2.50
Fixed in: 2.44



Subject: incoherent multiple backslash parsing
I've a small issue with Config::General > 2.44 The backslash escaping is not coherent. For example, the following config file: <tag E> disk disk,e\:\\ test,size </tag> parsed return this in version 2.44: $VAR1 = { 'tag' => { 'E' => { 'disk' => 'disk,e\\:\\\\ test,size' } } }; and for version > 2.44 return this: $VAR1 = { 'tag' => { 'E' => { 'disk' => 'disk,e\\:\\ test,size' } } } The \: => \\: in all version, but the \\ => \\\\ in version 2.44 and \\ in version > 2.44 It is definitively not what we expect. Thanks for you very good and useful module.
The escape system in older versions were incorrect and have been changed therefore by purpose. So, if you want to have two real backslashes in your output, you'll have to escape them BOTH. For example, put this in your config: path = \\\\server\\path to get: path = \\server\path
On Thu Dec 23 07:47:33 2010, TLINDEN wrote: Show quoted text
> The escape system in older versions were incorrect and have been changed > therefore by purpose. > > So, if you want to have two real backslashes in your output, you'll have > to escape them BOTH. > > For example, put this in your config: > > path = \\\\server\\path > > to get: > > path = \\server\path
I guess I was not clear enough, The processing from the config file and to the config file is not commutative. If I use this code: use Config::General qw(SaveConfig);; my $file = './test.conf'; my $file_out = './test_out.conf'; my $conf = new Config::General( -ConfigFile => $file,); my %config = $conf->getall; my $wr_conf = new Config::General(); $wr_conf->save_file( $file_out,\%config ); on this source file: <tag E> disk disk,e\:\\ test,size </tag> the new file created is like this: <tag> <E> disk disk,e\\:\\ test,size </E> </tag> with "e\\:\\ test,size" in place of "disk disk,e\:\\ test,size" Which is definitively wrong Best regards
Subject: Re: [rt.cpan.org #64169] incoherent multiple backslash parsing
Date: Thu, 23 Dec 2010 14:19:04 +0100
To: bug-Config-General [...] rt.cpan.org
From: DULAUNOY Fabrice <fabrice [...] dulaunoy.com>
On Thu, 23 Dec 2010 07:47:34 -0500 "T. Linden via RT" <bug-Config-General@rt.cpan.org> wrote: Mr Linden, I guess I was not clear enough, The processing from the config file and to the config file is not commutative. If I use this code: use Config::General qw(SaveConfig);; my $file = './test.conf'; my $file_out = './test_out.conf'; my $conf = new Config::General( -ConfigFile => $file,); my %config = $conf->getall; my $wr_conf = new Config::General(); $wr_conf->save_file( $file_out,\%config ); on this source file: <tag E> disk disk,e\:\\ test,size </tag> the new file created is like this: <tag> <E> disk disk,e\\:\\ test,size </E> </tag> with "e\\:\\ test,size" in place of "disk disk,e\:\\ test,size" Which is definitively wrong Best regards DULAUNOY Fabrice Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=64169 > > > The escape system in older versions were incorrect and have been changed > therefore by purpose. > > So, if you want to have two real backslashes in your output, you'll have > to escape them BOTH. > > For example, put this in your config: > > path = \\\\server\\path > > to get: > > path = \\server\path
-- +-----------------------------------------------------+ / |\ _,,,---,,_ /| / /,`.-'`' -. ;-;;,_ / | / |,4- ) )-,_. ,\ ( `'-' / | / '---''(_/--' `-'\_) / | +-----------------------------------------------------+ | | Dulaunoy Fabrice | | | | | | e-mail : fabrice@dulaunoy.com | | | : fabrice.dulaunoy@cegeka.be | | | | / | PGP fingerprint : | / | 9DD6 37BA D868 8F26 5283 CFA9 E9B3 49D8 7AC1 7E57 | / | Unix *is* userfriendly. | / | It's just selective which users it is friendly to. |/ +-----------------------------------------------------+
Well, the problem is, that the colon is no special char and doesn't have to be escaped. Therefore a config like this would result in what you need: disk = disk,e:\\ test,size - Tom
Subject: Re: [rt.cpan.org #64169] incoherent multiple backslash parsing
Date: Thu, 23 Dec 2010 16:08:18 +0100
To: bug-Config-General [...] rt.cpan.org
From: DULAUNOY Fabrice <fabrice [...] dulaunoy.com>
On Thu, 23 Dec 2010 09:47:03 -0500 "T. Linden via RT" <bug-Config-General@rt.cpan.org> wrote: Fine with me, but if I need the line 'as is'. Even putting the value in quote <tag E> disk "disk,e\:\\ test,size" </tag> or double quote <tag E> disk 'disk,e\:\\ test,size' </tag> result in the same output. <tag> <E> disk disk,e\\:\\ test,size </E> </tag> Is there a way to keep the value (terminal leaf) untouched. I really need this kind of behavior and I don't be very happy to change a production application and modify nearly 4000 configuration files. Maybe a new flag -KeepRawValue or -QuoteValue could be a possiblity And if it is not possible, don't worry, I will dig in my code to find a workaround. Best regards. Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=64169 > > > Well, the problem is, that the colon is no special char and doesn't have > to be escaped. Therefore a config like this would result in what you need: > > disk = disk,e:\\ test,size > > - Tom
-- +-----------------------------------------------------+ / |\ _,,,---,,_ /| / /,`.-'`' -. ;-;;,_ / | / |,4- ) )-,_. ,\ ( `'-' / | / '---''(_/--' `-'\_) / | +-----------------------------------------------------+ | | Dulaunoy Fabrice | | | | | | e-mail : fabrice@dulaunoy.com | | | : fabrice.dulaunoy@cegeka.be | | | | / | PGP fingerprint : | / | 9DD6 37BA D868 8F26 5283 CFA9 E9B3 49D8 7AC1 7E57 | / | Unix *is* userfriendly. | / | It's just selective which users it is friendly to. |/ +-----------------------------------------------------+
Subject: Re: [rt.cpan.org #64169] incoherent multiple backslash parsing
Date: Wed, 5 Jan 2011 10:28:11 +0100
To: bug-Config-General [...] rt.cpan.org
From: DULAUNOY Fabrice <fabrice [...] dulaunoy.com>
On Thu, 23 Dec 2010 09:47:03 -0500 "T. Linden via RT" <bug-Config-General@rt.cpan.org> wrote: Mister Linden, I understand your reasoning, but I need the data "as it". Because these data is used to feed another program ( where : is a special character ). I suggest this small patch that add the flag -NoEscape to allow the scalar entry to be used without any escaping Best regards Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=64169 > > > Well, the problem is, that the colon is no special char and doesn't have > to be escaped. Therefore a config like this would result in what you need: > > disk = disk,e:\\ test,size > > - Tom
-- +-----------------------------------------------------+ / |\ _,,,---,,_ /| / /,`.-'`' -. ;-;;,_ / | / |,4- ) )-,_. ,\ ( `'-' / | / '---''(_/--' `-'\_) / | +-----------------------------------------------------+ | | Dulaunoy Fabrice | | | | | | e-mail : fabrice@dulaunoy.com | | | : fabrice.dulaunoy@cegeka.be | | | | / | PGP fingerprint : | / | 9DD6 37BA D868 8F26 5283 CFA9 E9B3 49D8 7AC1 7E57 | / | Unix *is* userfriendly. | / | It's just selective which users it is friendly to. |/ +-----------------------------------------------------+

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

Are there any status updates on the resolution of this issue? We are experiencing this issue when calling ParseConfig on the following file content: <data> behaviour_in_question \$;blahblah;?(\$.path);path good_behaviour \@;blahblah;?(\@.path);path </data> We expect the following (when calling Data::Dumper on the %config): config $VAR1 = 'data'; $VAR2 = { 'behaviour_in_question' => '\\$;blahblah;?(\\$.path);path', 'good_behaviour' => '\\@;blahblah;?(\\@.path);path' }; but we get this instead (note the '\' preceding the '$' is being stripped in both cases): config $VAR1 = 'data'; $VAR2 = { 'behaviour_in_question' => '$;blahblah;?($.path);path', 'good_behaviour' => '\\@;blahblah;?(\\@.path);path' }; Thanks, Sean
Please note in the previous post I was using Config::General 2.49 with Perl 5.12 running on Gentoo 2.6.36. Applying the proposed patch fixed this issue for me. Also, downgrading to Config::General 2.42 fixed the problem.
patch applied in 2.51.