FileLog: better regexp checking

git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@5400 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig
2014-04-01 15:01:34 +00:00
parent cf2ffe74ac
commit 3ca62d5fe8

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;