From: Rafael Kitover Date: Wed, 11 Aug 2010 04:21:51 +0000 (+0000) Subject: fix field names with a single quote in them (patch from Jason Plum) X-Git-Tag: v0.09004~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6a4c729fe4ba22b065f7d733cbd1800ca84fb567;p=p5sagit%2FClass-Accessor-Grouped.git fix field names with a single quote in them (patch from Jason Plum) --- diff --git a/Changes b/Changes index 19fdb21..0d73b40 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,7 @@ Revision history for Class::Accessor::Grouped. (recommended by C::XSA author) - Modified internal cache names to avoid real accessor clashes - Some micro-optimizations for get_inherited + - Fixed field names with a single quote in them (patch from Jason Plum) 0.09003 Fri Apr 23 23:00:19 2010 - use Class::XSAccessor if available for 'simple' accessors, except on diff --git a/lib/Class/Accessor/Grouped.pm b/lib/Class/Accessor/Grouped.pm index 54410e4..a2dcb37 100644 --- a/lib/Class/Accessor/Grouped.pm +++ b/lib/Class/Accessor/Grouped.pm @@ -187,6 +187,8 @@ sub make_group_accessor { my $set = "set_$group"; my $get = "get_$group"; + $field =~ s/'/\\'/g; + # eval for faster fastiness my $code = eval "sub { if(\@_ > 1) { @@ -221,6 +223,8 @@ sub make_group_ro_accessor { my $get = "get_$group"; + $field =~ s/'/\\'/g; + my $code = eval "sub { if(\@_ > 1) { my \$caller = caller; @@ -256,6 +260,8 @@ sub make_group_wo_accessor { my $set = "set_$group"; + $field =~ s/'/\\'/g; + my $code = eval "sub { unless (\@_ > 1) { my \$caller = caller; @@ -480,6 +486,7 @@ Christopher H. Laco groditi: Guillermo Roditi ribasushi: Peter Rabbitson +Jason Plum =head1 COPYRIGHT & LICENSE diff --git a/t/lib/AccessorGroupsWO.pm b/t/lib/AccessorGroupsWO.pm index 459cc49..a0a2617 100644 --- a/t/lib/AccessorGroupsWO.pm +++ b/t/lib/AccessorGroupsWO.pm @@ -5,7 +5,7 @@ use base 'Class::Accessor::Grouped'; __PACKAGE__->mk_group_wo_accessors('single', 'singlefield'); __PACKAGE__->mk_group_wo_accessors('multiple', qw/multiple1 multiple2/); -__PACKAGE__->mk_group_wo_accessors('listref', [qw/lr1name lr1field/], [qw/lr2name lr2field/]); +__PACKAGE__->mk_group_wo_accessors('listref', [qw/lr1name lr1;field/], [qw/lr2name lr2'field/]); sub new { return bless {}, shift;