From c43f1030d1dc82e79f4cc1d3f822db2a60a7b17b Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Sun, 3 Jan 2016 12:34:27 +0000 Subject: [PATCH] fhem.pl: generate warning on : in reading or devicename git-svn-id: https://svn.fhem.de/fhem/trunk@10346 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/TcpServerUtils.pm | 2 +- fhem/fhem.pl | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/fhem/FHEM/TcpServerUtils.pm b/fhem/FHEM/TcpServerUtils.pm index a4ade2f3c..c2438bce6 100644 --- a/fhem/FHEM/TcpServerUtils.pm +++ b/fhem/FHEM/TcpServerUtils.pm @@ -109,7 +109,7 @@ TcpServer_Accept($$) } } - my $cname = "$type:$caddr:$port"; + my $cname = "${name}_${caddr}_${port}"; my %nhash; $nhash{NR} = $devcount++; $nhash{NAME} = $cname; diff --git a/fhem/fhem.pl b/fhem/fhem.pl index 968a3a7d6..177e6da62 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -1705,7 +1705,7 @@ CommandDefine($$) @a = split("[ \t][ \t]*", $def, 3); $ignoreErr = 1; } - if($a[0] && $a[0] eq "-temporary") { # Forum #39610 + if($a[0] && $a[0] eq "-temporary") { # Forum #39610, 46640 $def =~ s/\s*-temporary\s*//; @a = split("[ \t][ \t]*", $def, 3); $temporary = 1; @@ -1715,8 +1715,13 @@ CommandDefine($$) return "Usage: define " if(int(@a) < 2); return "$name already defined, delete it first" if(defined($defs{$name})); - return "Invalid characters in name (not A-Za-z0-9.:_): $name" + return "Invalid characters in name (not A-Za-z0-9._): $name" if($name !~ m/^[a-z0-9.:_]*$/i); + if($name =~ m/:/) { # Forum #45788 + my $msg = "unsupported character (:) in devicename $name"; + return $msg if($init_done); + Log 3, "WARNING: $msg"; + } my $m = $a[1]; if(!$modules{$m}) { # Perhaps just wrong case? @@ -2578,9 +2583,9 @@ CommandSetstate($$) next; } -# Log3 $d, 3, "WARNING: unsupported character in reading $sname ". -# "(not A-Za-z\\d_\\.-), notify the $d->{TYPE} module maintainer." -# if($sname !~ m/^[A-Za-z\d_\.-]+$/); + Log3 $d, 3, "WARNING: unsupported character in reading $sname ". + "(not A-Za-z\\d_\\.-), notify the $d->{TYPE} module maintainer." + if($sname !~ m/^[A-Za-z\d_\.-]+$/); if(!defined($d->{READINGS}{$sname}) || !defined($d->{READINGS}{$sname}{TIME}) ||