Skip to content

Commit

Permalink
Item13220: saving the formatting of PERL values is an utter, utter pa…
Browse files Browse the repository at this point in the history
…in in the arse
  • Loading branch information
Comment committed Jan 26, 2015
1 parent a1497fa commit 32ec4a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
15 changes: 8 additions & 7 deletions core/lib/Foswiki/Configure/Value.pm
Expand Up @@ -145,6 +145,13 @@ sub new {
return $this;
}

# Return true if this value is one of the preformatted types. Values for
# these types transfer verbatim from the UI to the LocalSite.cfg
sub isFormattedType {
my $this = shift;
return $this->{typename} eq 'PERL';
}

sub parseTypeParams {
my ( $this, $str ) = @_;

Expand Down Expand Up @@ -420,13 +427,7 @@ sub decodeValue {
# Empty string always interpreted as undef
return undef unless defined $value;

if ( $this->{typename} eq 'REGEX' ) {

# Regexes are stored as strings, because the conversion back
# and forth to regex objects is a PITA, and really a bit pointless.
return $value;
}
elsif ( $this->{typename} eq 'PERL' ) {
if ( $this->isFormattedType() ) {
my $value = eval($value);
die $@ if $@;
return $value;
Expand Down
6 changes: 5 additions & 1 deletion core/lib/Foswiki/Configure/Wizards/Save.pm
Expand Up @@ -443,7 +443,11 @@ sub _generateLSC {
unless ( $vs->CHECK_option('emptyok') );
}
my $d;
if ( exists $vs->{saving_value} ) {
if ( exists $vs->{saving_value}
&& $vs->isFormattedType() )
{

# This is used for the saving or formatted values, like PERL
$d = $vs->{saving_value};
}
else {
Expand Down

0 comments on commit 32ec4a6

Please sign in to comment.