From cbe885c7b90480553c117dccb9f74c219772a0d7 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Sat, 10 Oct 2009 16:18:30 +0000 Subject: [PATCH] 1.35 - the here-doc identifier in saved configs will now created in a way which avoids the existence of this identifier inside the here-doc, which if it happens results in weird behavior in the resulting config. git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@24 be1acefe-a474-0410-9a34-9b3221f2030f --- Changelog | 5 +++++ General.pm | 28 +++++++++++++++++++--------- README | 2 +- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/Changelog b/Changelog index af86bc8..1aa1edb 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,8 @@ + 1.35 - the here-doc identifier in saved configs will now created + in a way which avoids the existence of this identifier + inside the here-doc, which if it happens results in + weird behavior in the resulting config. + 1.34 - Danial Pearce reported a bug in _store(), which caused the module to create scalar entries even if the entry contained newlines. While diff --git a/General.pm b/General.pm index a5a1e0c..47be2f6 100644 --- a/General.pm +++ b/General.pm @@ -1,12 +1,11 @@ # # Config::General.pm - Generic Config Module # -# Purpose: Provide a convenient way -# for loading config values from a -# given file and return it as hash -# structure +# Purpose: Provide a convenient way for loading +# config values from a given file and +# return it as hash structure # -# Copyright (c) 2000-2001 Thomas Linden . +# Copyright (c) 2000-2002 Thomas Linden . # All Rights Reserved. Std. disclaimer applies. # Artificial License, same as perl itself. Have fun. # @@ -18,7 +17,7 @@ use strict; use Carp; use Exporter; -$Config::General::VERSION = "1.33"; +$Config::General::VERSION = "1.35"; use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @@ -616,12 +615,23 @@ sub _write_scalar { if ($line =~ /\n/) { # it is a here doc + my $delimiter; + my $tmplimiter = "EOF"; + while (!$delimiter) { + # create a unique here-doc identifier + if ($line =~ /$tmplimiter/s) { + $tmplimiter .= "%"; + } + else { + $delimiter = $tmplimiter; + } + } my @lines = split /\n/, $line; - $config_string .= $indent . $entry . " < =head1 VERSION -1.34 +1.35 =cut diff --git a/README b/README index d33997d..0cc801f 100644 --- a/README +++ b/README @@ -65,4 +65,4 @@ AUTHOR VERSION - 1.34 + 1.35