2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

fhem.pl: limit reading and attr name length in featurelevel 6.0+ (Forum #97493)

git-svn-id: https://svn.fhem.de/fhem/trunk@18617 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2019-02-17 09:24:01 +00:00
parent 9ef4f45234
commit 2dde2ca332
5 changed files with 42 additions and 9 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- feature: limit reading/attr name length in featurelevel 6.0+ (Forum #97493)
- feature: 49_SSCam: send recordings by telegram is integrated as well as
sending snapshots
- bugfix: 74_XiaomiBTLESens: fix Undefined subroutine

View File

@ -4123,6 +4123,16 @@ FW_show($$)
<br>
</ul>
</ul>
<a name="cmdshow"></a>
<h3>show</h3>
<ul>
<code>show [devspec]</code><br>
<br><br>
Show a temporary room with devices from &lt;devspec&gt;<br>
Note: this command is only available through the FHEMWEB interface
</ul>
=end html
=begin html_DE
@ -4844,6 +4854,16 @@ FW_show($$)
</ul></li>
</ul>
<a name="cmdshow"></a>
<h3>show</h3>
<ul>
<code>show [devspec]</code><br>
<br><br>
Zeigt einen tempor&auml;ren Raum mit dem Inhalt der &lt;devspec&gt;<br>
Achtung: dieser Befehl steht nur &uuml;ber das FHEMWEB Interface zur
Verf&uuml;gung.
</ul>
</ul>
=end html_DE

View File

@ -391,7 +391,8 @@ MQTT2_DEVICE_Attr($$)
"%JSONMAP"=>""));
return $ret if($ret);
} else {
return "unsupported character in readingname $par2"
return "bad reading name $par2 ".
"(contains not A-Za-z/\\d_\\.- or is too long)"
if(!goodReadingName($par2));
}

View File

@ -32,3 +32,7 @@ enable the old feature.
fhemSVG:openautomation:default. NOTE: the old version may be needed for
FLORRPLAN users
- the default fhem.cfg does not contain a telnet definition
- XXXX-XX-XX (6.0)
- attribute names can only consist of the character A-Za-z/\d_\.-
- the length of attribute and reading names must be 64 or less

View File

@ -2392,9 +2392,10 @@ CommandSetReading($$)
($err, @b) = ReplaceSetMagic($hash, 3, @a);
delete $hash->{CL};
}
return "WARNING: unsupported character in reading $b[1] ".
"(not A-Za-z/\\d_\\.-)" if(!goodReadingName($b[1]));
readingsSingleUpdate($defs{$sdev}, $b[1], $b[2], 1);
my $b1 = $b[1];
return "bad reading name $b1 (contains not A-Za-z/\\d_\\.- or is too long)"
if(!goodReadingName($b1));
readingsSingleUpdate($defs{$sdev}, $b1, $b[2], 1);
}
return join("\n", @rets);
}
@ -2830,12 +2831,15 @@ CommandAttr($$)
return "Usage: attr [-a|-r] <name> <attrname> [<attrvalue>]\n$namedef"
if(@a && @a < 2);
my $a1 = $a[1];
return "bad attribute name $a1 (contains not A-Za-z/\\d_\\.- or is too long)"
if($featurelevel > 5.9 && !goodReadingName($a1));
my @rets;
foreach my $sdev (devspec2array($a[0], $a[1] && $a[1] eq "?" ? undef : $cl)) {
foreach my $sdev (devspec2array($a[0], $a1 && $a1 eq "?" ? undef : $cl)) {
my $hash = $defs{$sdev};
my $attrName = $a[1];
my $attrName = $a1;
my $attrVal = (defined($a[2]) ? $a[2] : 1);
if(!defined($hash)) {
push @rets, "Please define $sdev first" if($init_done);#define -ignoreErr
@ -3045,8 +3049,8 @@ CommandSetstate($$)
next;
}
Log3 $d, 3, "WARNING: unsupported character in reading $sname ".
"(not A-Za-z/\\d_\\.-), notify the $d->{TYPE} module maintainer."
Log3 $d, 3,
"bad reading name $sname (contains not A-Za-z/\\d_\\.- or is too long)"
if(!goodReadingName($sname));
if(!defined($d->{READINGS}{$sname}) ||
@ -5700,7 +5704,9 @@ sub
goodReadingName($)
{
my ($name) = @_;
return ($name && ($name =~ m/^[a-z0-9._\-\/]+$/i || $name =~ m/^\./));
return undef if(!$name);
return undef if($featurelevel > 5.9 && length($name) > 64);
return ($name =~ m/^[a-z0-9._\-\/]+$/i || $name =~ m/^\./);
}
sub
@ -5710,6 +5716,7 @@ makeReadingName($) # Convert non-valid characters to _
$name = "UNDEFINED" if(!defined($name));
return $name if($name =~ m/^\./);
$name =~ s/[^a-z0-9._\-\/]/_/gi;
$name = substr($name, 0, 64) if($featurelevel > 5.9 && length($name) > 64);
return $name;
}