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:
parent
9ef4f45234
commit
2dde2ca332
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# 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
|
- feature: 49_SSCam: send recordings by telegram is integrated as well as
|
||||||
sending snapshots
|
sending snapshots
|
||||||
- bugfix: 74_XiaomiBTLESens: fix Undefined subroutine
|
- bugfix: 74_XiaomiBTLESens: fix Undefined subroutine
|
||||||
|
@ -4123,6 +4123,16 @@ FW_show($$)
|
|||||||
<br>
|
<br>
|
||||||
</ul>
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<a name="cmdshow"></a>
|
||||||
|
<h3>show</h3>
|
||||||
|
<ul>
|
||||||
|
<code>show [devspec]</code><br>
|
||||||
|
<br><br>
|
||||||
|
Show a temporary room with devices from <devspec><br>
|
||||||
|
Note: this command is only available through the FHEMWEB interface
|
||||||
|
</ul>
|
||||||
|
|
||||||
=end html
|
=end html
|
||||||
|
|
||||||
=begin html_DE
|
=begin html_DE
|
||||||
@ -4844,6 +4854,16 @@ FW_show($$)
|
|||||||
</ul></li>
|
</ul></li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<a name="cmdshow"></a>
|
||||||
|
<h3>show</h3>
|
||||||
|
<ul>
|
||||||
|
<code>show [devspec]</code><br>
|
||||||
|
<br><br>
|
||||||
|
Zeigt einen temporären Raum mit dem Inhalt der <devspec><br>
|
||||||
|
Achtung: dieser Befehl steht nur über das FHEMWEB Interface zur
|
||||||
|
Verfügung.
|
||||||
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
=end html_DE
|
=end html_DE
|
||||||
|
@ -391,7 +391,8 @@ MQTT2_DEVICE_Attr($$)
|
|||||||
"%JSONMAP"=>""));
|
"%JSONMAP"=>""));
|
||||||
return $ret if($ret);
|
return $ret if($ret);
|
||||||
} else {
|
} 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));
|
if(!goodReadingName($par2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,3 +32,7 @@ enable the old feature.
|
|||||||
fhemSVG:openautomation:default. NOTE: the old version may be needed for
|
fhemSVG:openautomation:default. NOTE: the old version may be needed for
|
||||||
FLORRPLAN users
|
FLORRPLAN users
|
||||||
- the default fhem.cfg does not contain a telnet definition
|
- 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
|
||||||
|
23
fhem/fhem.pl
23
fhem/fhem.pl
@ -2392,9 +2392,10 @@ CommandSetReading($$)
|
|||||||
($err, @b) = ReplaceSetMagic($hash, 3, @a);
|
($err, @b) = ReplaceSetMagic($hash, 3, @a);
|
||||||
delete $hash->{CL};
|
delete $hash->{CL};
|
||||||
}
|
}
|
||||||
return "WARNING: unsupported character in reading $b[1] ".
|
my $b1 = $b[1];
|
||||||
"(not A-Za-z/\\d_\\.-)" if(!goodReadingName($b[1]));
|
return "bad reading name $b1 (contains not A-Za-z/\\d_\\.- or is too long)"
|
||||||
readingsSingleUpdate($defs{$sdev}, $b[1], $b[2], 1);
|
if(!goodReadingName($b1));
|
||||||
|
readingsSingleUpdate($defs{$sdev}, $b1, $b[2], 1);
|
||||||
}
|
}
|
||||||
return join("\n", @rets);
|
return join("\n", @rets);
|
||||||
}
|
}
|
||||||
@ -2830,12 +2831,15 @@ CommandAttr($$)
|
|||||||
|
|
||||||
return "Usage: attr [-a|-r] <name> <attrname> [<attrvalue>]\n$namedef"
|
return "Usage: attr [-a|-r] <name> <attrname> [<attrvalue>]\n$namedef"
|
||||||
if(@a && @a < 2);
|
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;
|
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 $hash = $defs{$sdev};
|
||||||
my $attrName = $a[1];
|
my $attrName = $a1;
|
||||||
my $attrVal = (defined($a[2]) ? $a[2] : 1);
|
my $attrVal = (defined($a[2]) ? $a[2] : 1);
|
||||||
if(!defined($hash)) {
|
if(!defined($hash)) {
|
||||||
push @rets, "Please define $sdev first" if($init_done);#define -ignoreErr
|
push @rets, "Please define $sdev first" if($init_done);#define -ignoreErr
|
||||||
@ -3045,8 +3049,8 @@ CommandSetstate($$)
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log3 $d, 3, "WARNING: unsupported character in reading $sname ".
|
Log3 $d, 3,
|
||||||
"(not A-Za-z/\\d_\\.-), notify the $d->{TYPE} module maintainer."
|
"bad reading name $sname (contains not A-Za-z/\\d_\\.- or is too long)"
|
||||||
if(!goodReadingName($sname));
|
if(!goodReadingName($sname));
|
||||||
|
|
||||||
if(!defined($d->{READINGS}{$sname}) ||
|
if(!defined($d->{READINGS}{$sname}) ||
|
||||||
@ -5700,7 +5704,9 @@ sub
|
|||||||
goodReadingName($)
|
goodReadingName($)
|
||||||
{
|
{
|
||||||
my ($name) = @_;
|
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
|
sub
|
||||||
@ -5710,6 +5716,7 @@ makeReadingName($) # Convert non-valid characters to _
|
|||||||
$name = "UNDEFINED" if(!defined($name));
|
$name = "UNDEFINED" if(!defined($name));
|
||||||
return $name if($name =~ m/^\./);
|
return $name if($name =~ m/^\./);
|
||||||
$name =~ s/[^a-z0-9._\-\/]/_/gi;
|
$name =~ s/[^a-z0-9._\-\/]/_/gi;
|
||||||
|
$name = substr($name, 0, 64) if($featurelevel > 5.9 && length($name) > 64);
|
||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user