10_MQTT2_DEVICE.pm: check the regexp in the readingList (Forum #126969)

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@25888 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2022-03-27 10:22:58 +00:00
parent c00e5d63b3
commit 5e340b9159
2 changed files with 5 additions and 1 deletions

View File

@ -474,6 +474,10 @@ MQTT2_DEVICE_Attr($$)
return "$dev attr $attrName: more parameters needed" if(!$par2); return "$dev attr $attrName: more parameters needed" if(!$par2);
if($atype eq "reading") { if($atype eq "reading") {
$par1 =~ s/\$[a-z0-9_]+/\.\*/gi;
eval { "Hallo" =~ m/^$par1$/ };
return "Bad regexp in $dev readingList: $@" if($@);
if($par2 =~ m/^{.*}\s*$/) { if($par2 =~ m/^{.*}\s*$/) {
my %v = ("%TOPIC"=>1, "%EVENT"=>"0 1 2 3 4 5 6 7 8 9", my %v = ("%TOPIC"=>1, "%EVENT"=>"0 1 2 3 4 5 6 7 8 9",
"%NAME"=>$dev, "%CID"=>"clientId", "%JSONMAP"=>""); "%NAME"=>$dev, "%CID"=>"clientId", "%JSONMAP"=>"");

View File

@ -55,7 +55,7 @@ notify_Define($$)
# Checking for misleading regexps # Checking for misleading regexps
return "Bad regexp: starting with *" if($re =~ m/^\*/); return "Bad regexp: starting with *" if($re =~ m/^\*/);
eval { "Hallo" =~ m/^$re$/ }; eval { "Hallo" =~ m/^$re$/ };
return "Bad regexp: $@" if($@); return "Bad regexp in $name definition: $@" if($@);
$hash->{REGEXP} = $re; $hash->{REGEXP} = $re;
my %specials= ( my %specials= (
"%NAME" => $name, "%NAME" => $name,