2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

FileLog: better regexp checking

git-svn-id: https://svn.fhem.de/fhem/trunk@5400 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2014-04-01 15:01:34 +00:00
parent ca193cd9f7
commit 511c23bb50

View File

@ -57,6 +57,7 @@ FileLog_Define($@)
return "wrong syntax: define <name> FileLog filename regexp" if(int(@a) != 4);
return "Bad regexp: starting with *" if($re =~ m/^\*/);
eval { "Hallo" =~ m/^$a[3]$/ };
return "Bad regexp: $@" if($@);
@ -215,6 +216,7 @@ FileLog_Set($@)
map { $h{$_} = 1 } split(/\|/, $hash->{REGEXP});
$h{$re} = 1;
$re = join("|", sort keys %h);
return "Bad regexp: starting with *" if($re =~ m/^\*/);
eval { "Hallo" =~ m/^$re$/ };
return "Bad regexp: $@" if($@);
$hash->{REGEXP} = $re;
@ -228,6 +230,7 @@ FileLog_Set($@)
return "Cannot remove last regexp part" if(int(keys(%h)) == 1);
delete $h{$a[2]};
my $re = join("|", sort keys %h);
return "Bad regexp: starting with *" if($re =~ m/^\*/);
eval { "Hallo" =~ m/^$re$/ };
return "Bad regexp: $@" if($@);
$hash->{REGEXP} = $re;