diff --git a/fhem/CHANGED b/fhem/CHANGED index 09d04767d..fb7bf54ed 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -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. + - bugfix: 21_HEOS: decode_json() in a eval, fix play_previous - bugfix: 73_NUKIBridge/74_NUKIDevice: decode_json() in a eval - Update: 73_AMADCommBridge/74AMADDevice: 4.2 new Version with Tasker Support - bugfix: 14_CUL_TCM97001: Fix temperature reading diff --git a/fhem/FHEM/21_HEOSGroup.pm b/fhem/FHEM/21_HEOSGroup.pm index cd182a54a..f134e5dbc 100644 --- a/fhem/FHEM/21_HEOSGroup.pm +++ b/fhem/FHEM/21_HEOSGroup.pm @@ -38,7 +38,7 @@ use JSON qw(decode_json); use Encode qw(encode_utf8); -my $version = "1.0.0"; +my $version = "1.0.3"; @@ -433,8 +433,13 @@ sub HEOSGroup_Parse($$) { my $decode_json; my $code; + + $decode_json = eval{decode_json(encode_utf8($json))}; + if($@){ + Log3 $name, 3, "HEOSGroup ($name) - JSON error while request: $@"; + return; + } - $decode_json = decode_json(encode_utf8($json)); Log3 $name, 4, "HEOSGroup ($name) - ParseFn wurde aufgerufen"; if( defined($decode_json->{gid}) ) { diff --git a/fhem/FHEM/21_HEOSMaster.pm b/fhem/FHEM/21_HEOSMaster.pm index 821e12a88..92528fb86 100644 --- a/fhem/FHEM/21_HEOSMaster.pm +++ b/fhem/FHEM/21_HEOSMaster.pm @@ -65,7 +65,7 @@ eval "use Encode;1" or $missingModul .= "Encode "; -my $version = "1.0.2"; +my $version = "1.0.3"; my %heosCmds = ( 'enableChangeEvents' => 'system/register_for_change_events?enable=', @@ -94,7 +94,7 @@ my %heosCmds = ( 'setMute' => 'player/set_mute?', 'setGroupMute' => 'group/set_mute?', 'playNext' => 'player/play_next?', - 'playPrev' => 'player/play_prev?', + 'playPrev' => 'player/play_previous?', 'playPresetStation' => 'browse/play_preset?', 'playInput' => 'browse/play_input?', 'playStream' => 'browse/play_stream?', @@ -228,7 +228,7 @@ sub HEOSMaster_Undef($$) { HEOSMaster_Close($hash); delete $modules{HEOSMaster}{defptr}{$hash->{HOST}}; - Log3 $name, 3, "HEOSPlayer ($name) - device $name deleted"; + Log3 $name, 3, "HEOSMaster ($name) - device $name deleted"; return undef; } @@ -514,7 +514,12 @@ sub HEOSMaster_ProcessRead($$) { $hash->{LAST_RECV} = time(); Log3 $name, 5, "HEOSMaster ($name) - Decoding JSON message. Length: " . length($json) . " Content: " . $json; - my $obj = decode_json($json); + + my $obj = eval{decode_json($json)}; + if($@){ + Log3 $name, 3, "HEOSMaster ($name) - JSON error while request: $@"; + return; + } if(defined($obj->{heos})) { @@ -548,7 +553,11 @@ sub HEOSMaster_ResponseProcessing($$) { unless( defined($json)); Log3 $name, 4, "HEOSMaster ($name) - JSON detected!"; - $decode_json = decode_json(encode_utf8($json)); + $decode_json = eval{decode_json(encode_utf8($json))}; + if($@){ + Log3 $name, 3, "HEOSMaster ($name) - JSON error while request: $@"; + return; + } return Log3 $name, 3, "HEOSMaster ($name) - decode_json has no Hash" unless(ref($decode_json) eq "HASH"); diff --git a/fhem/FHEM/21_HEOSPlayer.pm b/fhem/FHEM/21_HEOSPlayer.pm index 2d3d6426f..e2a37f62c 100644 --- a/fhem/FHEM/21_HEOSPlayer.pm +++ b/fhem/FHEM/21_HEOSPlayer.pm @@ -39,7 +39,7 @@ use Encode qw(encode_utf8); use URI::Escape; #use Data::Dumper; -my $version = "1.0.2"; +my $version = "1.0.3"; @@ -790,8 +790,13 @@ sub HEOSPlayer_Parse($$) { my $decode_json; my $code; + + $decode_json = eval{decode_json(encode_utf8($json))}; + if($@){ + Log3 $name, 3, "HEOSPlayer ($name) - JSON error while request: $@"; + return; + } - $decode_json = decode_json(encode_utf8($json)); Log3 $name, 4, "HEOSPlayer - ParseFn wurde aufgerufen"; if( defined($decode_json->{pid}) ) {