73_NUKIBridge: 74_NUKIDevice decode_json() in a eval

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@16284 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
LeonGaultier 2018-02-27 10:55:46 +00:00
parent d33312dbd9
commit 6a3e7f7283
3 changed files with 26 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. # 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.
- bugfix: 73_NUKIBridge/74_NUKIDevice: decode_json() in a eval
- Update: 73_AMADCommBridge/74AMADDevice: 4.2 new Version with Tasker Support - Update: 73_AMADCommBridge/74AMADDevice: 4.2 new Version with Tasker Support
- bugfix: 14_CUL_TCM97001: Fix temperature reading - bugfix: 14_CUL_TCM97001: Fix temperature reading
- bugfix: 49_SSCam: V3.3.0, code review, API bug fix of runview lastrec, - bugfix: 49_SSCam: V3.3.0, code review, API bug fix of runview lastrec,

View File

@ -46,7 +46,7 @@ use JSON;
use HttpUtils; use HttpUtils;
my $version = "0.6.1"; my $version = "0.6.2";
my $bridgeapi = "1.5"; my $bridgeapi = "1.5";
@ -477,7 +477,11 @@ sub NUKIBridge_ResponseProcessing($$$) {
return "NUKIBridge ($name) - invalid json detected: $json"; return "NUKIBridge ($name) - invalid json detected: $json";
} }
$decode_json = decode_json($json); my $decode_json = eval{decode_json($json)};
if($@){
Log3 $name, 3, "NUKIBridge ($name) - JSON error while request: $@";
return;
}
if( ref($decode_json) eq "ARRAY" and scalar(@{$decode_json}) > 0 and $path eq "list" ) { if( ref($decode_json) eq "ARRAY" and scalar(@{$decode_json}) > 0 and $path eq "list" ) {
@ -745,7 +749,11 @@ sub NUKIBridge_CallBlocking($$$) {
} }
my $decode_json = decode_json($data); my $decode_json = eval{decode_json($data)};
if($@){
Log3 $name, 3, "NUKIBridge ($name) - JSON error while request: $@";
return;
}
return undef if( !$decode_json ); return undef if( !$decode_json );

View File

@ -33,7 +33,7 @@ use warnings;
use JSON; use JSON;
my $version = "0.6.1"; my $version = "0.6.2";
@ -414,7 +414,11 @@ sub NUKIDevice_Parse($$) {
######################################### #########################################
#### verarbeiten des JSON Strings ####### #### verarbeiten des JSON Strings #######
my $decode_json = decode_json($result); my $decode_json = eval{decode_json($result)};
if($@){
Log3 $name, 3, "NUKIDevice ($name) - JSON error while request: $@";
return;
}
if( ref($decode_json) ne "HASH" ) { if( ref($decode_json) ne "HASH" ) {
@ -527,7 +531,11 @@ sub NUKIDevice_CGI() {
return "NUKIDevice ($name) - invalid json detected: $json"; return "NUKIDevice ($name) - invalid json detected: $json";
} }
my $decode_json = decode_json($json); my $decode_json = eval{decode_json($json)};
if($@){
Log3 $name, 3, "NUKIDevice ($name) - JSON error while request: $@";
return;
}
if( ref($decode_json) eq "HASH" ) { if( ref($decode_json) eq "HASH" ) {