Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Item12952: PERL types get corrupted when updated
Fixes two issues:

1) When a multi-line set is submitted through jsonrpc, the
untaint regex is not multi-line and truncates it at the first line.

2) Type PERL are stored as "ref" types HASH or ARRAY,  but are input as quoted
strings when saved from jsonrpc set.

SMELL ...   Simple quoted strings of type PERL still get corrupted.  After a save,
the quotes have been stripped.

  - $Foswiki::cfg{Plugins}{ConfigurePlugin}{Test}{PERL} = 'PERL';

ends up stored as
  - $Foswiki::cfg{Plugins}{ConfigurePlugin}{Test}{PERL} = PERL;

This results in a corrupted LocalSite.cfg.  This can be fixed by
starting with the following in the Spec file:

  - $Foswiki::cfg{Plugins}{ConfigurePlugin}{Test}{PERL} = '\'PERL\';';
  • Loading branch information
gac410 committed Oct 14, 2014
1 parent d66593a commit 13841b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Expand Up @@ -32,7 +32,7 @@ $Foswiki::cfg{Plugins}{ConfigurePlugin}{Test}{PASSWORD} = 'PASSWORD';
# Should be PATH
$Foswiki::cfg{Plugins}{ConfigurePlugin}{Test}{PATH} = 'PATH';
# **PERL**
$Foswiki::cfg{Plugins}{ConfigurePlugin}{Test}{PERL} = 'PERL';
$Foswiki::cfg{Plugins}{ConfigurePlugin}{Test}{PERL} = '\'PERL\';';
# **REGEX**
# Should be /^regex$/
$Foswiki::cfg{Plugins}{ConfigurePlugin}{Test}{REGEX} = qr/^regex$/;
Expand Down
9 changes: 8 additions & 1 deletion core/lib/Foswiki/Configure/Wizards/Save.pm
Expand Up @@ -201,7 +201,7 @@ sub save {
# Import sets without expanding
if ( $this->param('set') ) {
while ( my ( $k, $v ) = each %{ $this->param('set') } ) {
if ( defined $v && $v =~ /(.*)/ ) {
if ( defined $v && $v =~ /(.*)/s ) {
eval "\$Foswiki::cfg" . _perlKeys($k) . "=\$1";
}
else {
Expand Down Expand Up @@ -341,6 +341,13 @@ sub _spec_dump {
elsif ( $vs->{typename} eq 'NUMBER' ) {
$d = $datum;
}

# SMELL: Perl Datatype comes in from JSON as a quoted string,
# but might be stored as a HASH or ARRAY,
elsif ( $vs->{typename} eq 'PERL' && !ref($datum) ) {
print STDERR "Setting $keys to ($datum)\n";
$d = "$datum";
}
else {
$d = Data::Dumper->Dump( [$datum] );
$d =~ s/^\$VAR1\s*=\s*//s;
Expand Down

0 comments on commit 13841b7

Please sign in to comment.