2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

75_MSG: eval for wrong JSON format

git-svn-id: https://svn.fhem.de/fhem/trunk@10546 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2016-01-17 01:11:52 +00:00
parent 0b70532179
commit 66717398fc

View File

@ -157,12 +157,21 @@ s/^[\s\t]*([!]?(([A-Za-z0-9%+._-])*@([%+a-z0-9A-Z.-]+))[\w,@.!|:]*)[\s\t]+//
# check for advanced options # check for advanced options
if ( $msg =~ s/[\s\t]*O(\[\{.*\}\])[\s\t]*$// ) { if ( $msg =~ s/[\s\t]*O(\[\{.*\}\])[\s\t]*$// ) {
Log3 $globalDevName, 5, "msg: found options=$1";
# Use JSON module if possible # Use JSON module if possible
eval 'use JSON qw( decode_json ); 1'; eval 'use JSON qw( decode_json ); 1';
if ( !$@ ) { if ( !$@ ) {
$advanced = decode_json( Encode::encode_utf8($1) ); eval '$advanced = decode_json( Encode::encode_utf8($1) ); 1';
if (!$@) {
Log3 $globalDevName, 5, Log3 $globalDevName, 5,
"msg: Advanced options\n" . Dumper($advanced); "msg: Decoded advanced options\n" . Dumper($advanced);
}
else {
Log3 $globalDevName, 5,
"msg: Error decoding JSON for advanced options";
$advanced = "";
}
} }
else { else {
Log3 $globalDevName, 3, Log3 $globalDevName, 3,