[Bps-public-commit] Config-GitLike branch, master, updated. 1.00-15-g4419310
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Fri Aug 14 08:11:18 EDT 2009
The branch, master has been updated
via 4419310f6b6cadff42a7a1fc407827127b253e6d (commit)
from b614beaa88256050ec30d7b16d41072b9a94bc09 (commit)
Summary of changes:
lib/Config/GitLike.pm | 35 ++++++++++++++++++++++++-----------
1 files changed, 24 insertions(+), 11 deletions(-)
- Log -----------------------------------------------------------------
commit 4419310f6b6cadff42a7a1fc407827127b253e6d
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Aug 14 20:11:10 2009 +0800
bug fixed: previous check for unescaped \ or " in subsection is lame.
diff --git a/lib/Config/GitLike.pm b/lib/Config/GitLike.pm
index 6ed0caa..f669005 100644
--- a/lib/Config/GitLike.pm
+++ b/lib/Config/GitLike.pm
@@ -227,13 +227,22 @@ sub parse_content {
# same rules as for sections
elsif ($c =~ s/$section_regex//) {
$section = lc $1;
- return $args{error}->(
- content => $args{content},
- offset => $offset,
- # don't allow quoted subsections to contain unquoted
- # double-quotes or backslashes
- ) if $2 && $2 =~ /(?<!\\)(?:"|\\)/;
- $section .= ".$2" if defined $2;
+ if ($2) {
+ my $subsection = $2;
+ my $check = $2;
+ $check =~ s!\\\\!!g;
+ $check =~ s!\\"!!g;
+ return $args{error}->(
+ content => $args{content},
+ offset => $offset,
+
+ # don't allow quoted subsections to contain unquoted
+ # double-quotes or backslashes
+ ) if $check =~ /\\|"/;
+
+ $section .= ".$subsection";
+ }
+
$args{callback}->(
section => $section,
offset => $offset,
@@ -613,7 +622,6 @@ sub format_section {
if ($args{section} =~ /^(.*?)\.(.*)$/) {
my ($section, $subsection) = ($1, $2);
- $subsection =~ s/(["\\])/\\$1/g;
my $ret = qq|[$section "$subsection"]|;
$ret .= "\n" unless $args{bare};
return $ret;
@@ -705,9 +713,14 @@ sub group_set {
die "Invalid section name $section\n"
if $self->_invalid_section_name($section);
- die "Unescaped backslash or \" in subsection $subsection\n"
- if defined $subsection && $subsection =~ /(?<!\\)(?:"|\\)/;
-
+ if ( defined $subsection ) {
+ my $check = $subsection;
+ $check =~ s!\\\\!!g;
+ $check =~ s!\\"!!g;
+ die "Unescaped backslash or \" in subsection $subsection\n"
+ if $check =~ /\\|"/;
+ }
+
$args{value} = $self->cast(
value => $args{value},
as => $args{as},
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list