Skip to content

Commit

Permalink
Item12952: fix data representations for clean UI communication. Ensur…
Browse files Browse the repository at this point in the history
…e legal defaults in bootstrap configuration
  • Loading branch information
crawford committed Aug 28, 2014
1 parent 6904c15 commit fac88d8
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 16 deletions.
2 changes: 1 addition & 1 deletion core/lib/Foswiki.spec
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ $Foswiki::cfg{PluralToSingular} = $TRUE;
# Foswiki supports different back-end store implementations.
# **SELECTCLASS Foswiki::Store::* **
# Store implementation.
$Foswiki::cfg{Store}{Implementation} = '';
$Foswiki::cfg{Store}{Implementation} = 'Foswiki::Store::PlainFile';
# **PERL EXPERT**
# Customisation of the Foswiki Store implementation. This allows
Expand Down
11 changes: 7 additions & 4 deletions core/lib/Foswiki/Configure/Checkers/AccessibleCFG.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ package Foswiki::Configure::Checkers::AccessibleCFG;
use strict;
use warnings;

use Assert;

use Foswiki::Configure::Checkers::PERL ();
our @ISA = ('Foswiki::Configure::Checkers::PERL');

sub check_current_value {
my ( $this, $reporter ) = @_;

my $val = $this->getCfg();
unless ( ref($val) eq 'ARRAY' ) {
$reporter->ERROR("Was expecting this to be an array");
my $val = $Foswiki::cfg{AccessibleCFG};

if ( ref($val) ne 'ARRAY' ) {
$reporter->ERROR('Must be an array');
return;
}
my $ec = 0;
foreach my $v (@$val) {
if ( ref($v) ne 'SCALAR' ) {
if ( ref($v) ) {
$reporter->ERROR("Was expecting entry $ec to be a scalar");
}
if ( $v !~ /^({\w+})+$/ ) {
Expand Down
9 changes: 5 additions & 4 deletions core/lib/Foswiki/Configure/Checkers/MinPasswordLength.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');

sub check_current_value {
my ($this, $reporter) = @_;
my ( $this, $reporter ) = @_;

return if ($Foswiki::cfg{MinPasswordLength} > 7);
return if ( $Foswiki::cfg{MinPasswordLength} >= 7 );

if ($Foswiki::cfg{MinPasswordLength}) {
if ( $Foswiki::cfg{MinPasswordLength} ) {
$reporter->WARN('Allowing passwords < 7 characters is insecure.');
} else {
}
else {
$reporter->WARN('Allowing null passwords is VERY insecure.');
}
}
Expand Down
11 changes: 8 additions & 3 deletions core/lib/Foswiki/Configure/LoadSpec.pm
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,18 @@ sub _parse {

# Record the value *string*, internal formatting et al.
ASSERT( UNTAINTED($value), $value ) if DEBUG;
if ( $value =~ /^qr\/(.*)\/$/ ) {
if ( $open->{typename} eq 'REGEX' ) {

# regexp; convert to string
$value = eval $value;
$value = "$value";
$value =~ s/'/\\'/g;
$value = "'$value'";
}
elsif ( $open->{typename} eq 'PERL' ) {

# PERL - convert to string
my $var1 = Data::Dumper->Dump( [$value] );
$var1 =~ s/^.*=\s*//;
$value = $var1;
}
$open->{default} = $value;

Expand Down
20 changes: 16 additions & 4 deletions core/lib/Foswiki/Configure/Value.pm
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ use Data::Dumper ();
use Foswiki::Configure::Item ();
our @ISA = ('Foswiki::Configure::Item');

use Foswiki::Configure::FileUtil ();

# Options valid in a .spec for a leaf value
use constant ATTRSPEC => {
FEEDBACK => { parse_val => '_FEEDBACK' },
Expand Down Expand Up @@ -122,25 +124,35 @@ sub parseTypeParams {
# SELECT types *always* start with a comma-separated list of
# things to select from. These things may be words or wildcard
# class specifiers, or quoted strings (no internal quotes)
$this->{select_from} = [];
my @picks = ();
do {
if ( $str =~ s/^\s*(["'])(.*?)\1// ) {
push( @{ $this->{select_from} }, $2 );
push( @picks, $2 );
}
elsif ( $str =~ s/^\s*([-A-Za-z0-9:.*]*)// ) {
push( @{ $this->{select_from} }, defined $1 ? $1 : '' );
my $v = $1;
$v = '' unless defined $v;
if ( $v =~ /\*/ && $this->{typename} eq 'SELECTCLASS' ) {

# Populate the class list
push( @picks,
Foswiki::Configure::FileUtil::findPackages($v) );
}
else {
push( @picks, $v );
}
}
else {
die "Illegal .spec at $str";
}
} while ( $str =~ s/\s*,// );
$this->{select_from} = [@picks];
}
elsif ( $str =~ s/^\s*(\d+(?:x\d+)?)// ) {

# Width specifier for e.g. STRING
$this->{SIZE} = $1;
}

return $str;
}

Expand Down

0 comments on commit fac88d8

Please sign in to comment.