From ae7febe69d75acfceea82d20711fb88cd627e1b6 Mon Sep 17 00:00:00 2001 From: Xavier Guimard Date: Tue, 9 Feb 2016 22:17:42 +0000 Subject: [PATCH] Add extended functions in locationRules test (may close #924) --- .../lib/Lemonldap/NG/Manager/Attributes.pm | 24 ++++++++++++------- .../Lemonldap/NG/Manager/Build/Attributes.pm | 22 +++++++++++------ 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Attributes.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Attributes.pm index 60b52d3bb..abb04eb87 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Attributes.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Attributes.pm @@ -1082,14 +1082,22 @@ qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0- my ( $val, $conf ) = @_; my $s = $val; $s =~ s/\b(accept|deny)\b/1/g; - if ( $conf->{'customFunctions'} ) { - foreach my $f ( - split( /\s+/, $conf->{'customFunctions'}, 0 ) ) - { - return 0, "__badCustomFuncName__ $f" - unless $f =~ /^\w+$/; - $s = "sub $f {1} $s"; - } + foreach my $f ( + split( + /\s+/, + ( + defined $conf->{'customFunctions'} + ? "$conf->{'customFunctions'} " + : '' + ) + . 'checkLogonHours date checkDate basic unicode2iso iso2unicode groupMatch', + 0 + ) + ) + { + return 0, "__badCustomFuncName__ $f" + unless $f =~ /^[a-zA-Z]\w*$/; + $s = "sub $f {1} $s"; } eval $s; return $@ ? ( 0, "__badExpression__: $@" ) : 1; diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build/Attributes.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build/Attributes.pm index a928fd831..011c048a3 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build/Attributes.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build/Attributes.pm @@ -884,13 +884,21 @@ sub attributes { my ( $val, $conf ) = @_; my $s = $val; $s =~ s/\b(accept|deny)\b/1/g; - if ( $conf->{customFunctions} ) { - foreach my $f ( split /\s+/, $conf->{customFunctions} ) - { - return ( 0, "__badCustomFuncName__ $f" ) - unless ( $f =~ /^\w+$/ ); - $s = "sub $f {1} $s"; - } + foreach my $f ( + split( + /\s+/, + ( + defined $conf->{customFunctions} + ? "$conf->{customFunctions} " + : '' + ) + . 'checkLogonHours date checkDate basic unicode2iso iso2unicode groupMatch', + ) + ) + { + return ( 0, "__badCustomFuncName__ $f" ) + unless ( $f =~ /^[a-zA-Z]\w*$/ ); + $s = "sub $f {1} $s"; } eval $s; return $@ ? ( 0, "__badExpression__: $@" ) : (1);