mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
10_MQTT2_DEVICE.pm: CheckRegexp with devicetopic for readingList (Forum #126969)
git-svn-id: https://svn.fhem.de/fhem/trunk@25889 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
493ca454f7
commit
7a328160c4
@ -474,10 +474,6 @@ 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"=>"");
|
||||||
@ -625,10 +621,11 @@ MQTT2_DEVICE_addReading($$)
|
|||||||
next if($line eq "");
|
next if($line eq "");
|
||||||
my ($re,$code) = split(" ", $line,2);
|
my ($re,$code) = split(" ", $line,2);
|
||||||
return "ERROR: empty code in line >$line< for $name" if(!defined($code));
|
return "ERROR: empty code in line >$line< for $name" if(!defined($code));
|
||||||
|
|
||||||
|
map { $re =~ s/\$$_/$hash->{".DT"}{$_}/g } keys %{$hash->{".DT"}};
|
||||||
my $errMsg = CheckRegexp($re, "readingList attribute for $name");
|
my $errMsg = CheckRegexp($re, "readingList attribute for $name");
|
||||||
return $errMsg if($errMsg);
|
return $errMsg if($errMsg);
|
||||||
|
|
||||||
map { $re =~ s/\$$_/$hash->{".DT"}{$_}/g } keys %{$hash->{".DT"}};
|
|
||||||
if($cid && $re =~ m/^$cid:/) {
|
if($cid && $re =~ m/^$cid:/) {
|
||||||
if($re =~ m/^$cid:([^\\\?.*\[\](|)]+):\.\*$/) { # cid:topic:.*
|
if($re =~ m/^$cid:([^\\\?.*\[\](|)]+):\.\*$/) { # cid:topic:.*
|
||||||
$modules{MQTT2_DEVICE}{defptr}{"re:$cid:$1"}{$re}{"$name,$code"} = 1;
|
$modules{MQTT2_DEVICE}{defptr}{"re:$cid:$1"}{$re}{"$name,$code"} = 1;
|
||||||
|
@ -6396,8 +6396,15 @@ CheckRegexp($$)
|
|||||||
my ($re,$context) = @_;
|
my ($re,$context) = @_;
|
||||||
return "Empty regexp in $context" if(!defined($re));
|
return "Empty regexp in $context" if(!defined($re));
|
||||||
return "Bad regexp >$re< in $context" if($re =~ m/^[*+]/);
|
return "Bad regexp >$re< in $context" if($re =~ m/^[*+]/);
|
||||||
|
|
||||||
|
my $warn;
|
||||||
|
my $osig = $SIG{__WARN__};
|
||||||
|
$SIG{__WARN__} = sub { $warn = @_[0]};
|
||||||
eval { "Hallo" =~ m/^$re$/ };
|
eval { "Hallo" =~ m/^$re$/ };
|
||||||
|
$SIG{__WARN__} = $osig;
|
||||||
|
|
||||||
return "Bad regexp >$re< in $context: $@" if($@);
|
return "Bad regexp >$re< in $context: $@" if($@);
|
||||||
|
return "Bad regexp >$re< in $context: $warn" if($warn);
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user