From 2d9828aa055eefbd9de0c02f46fe6e101914d534 Mon Sep 17 00:00:00 2001
From: ra666ack <>
Date: Mon, 21 Dec 2015 21:53:13 +0000
Subject: [PATCH] 71_YAMAHA_NP: More secure FM frequency input.
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@10227 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
FHEM/71_YAMAHA_NP.pm | 78 ++++++++++++++++++++++----------------------
fhem.cfg | 18 ++++++++--
2 files changed, 55 insertions(+), 41 deletions(-)
diff --git a/FHEM/71_YAMAHA_NP.pm b/FHEM/71_YAMAHA_NP.pm
index 8172414b1..292d7f899 100644
--- a/FHEM/71_YAMAHA_NP.pm
+++ b/FHEM/71_YAMAHA_NP.pm
@@ -703,45 +703,45 @@ sub YAMAHA_NP_Set
}
elsif($what eq "tunerFMFrequency")
{
- if(length($a[2]) <= 6 and length($a[2]) >= 5) # Check the string length (x)xx.xx
- {
- if ( $a[2] =~ /^[0-9,.E]+$/ ) # Check if value is numeric
- {
- if( $a[2] >= 87.50 and $a[2] <= 108.00) # Check if within the value range
- {
- if(substr($a[2], -3, 1) eq '.') # Check for decimal point
- {
- my $lastDigit = substr($a[2], -1, 1);
- if(($lastDigit eq "0") or ($lastDigit eq "5"))
- {
- my $frequency = $a[2];
- $frequency =~ s/\.//; # Remove decimal point
- YAMAHA_NP_SendCommand($hash, "".$frequency."<\/Freq><\/FM><\/Tuning><\/Play_Control><\/Tuner>", "tunerFMFrequency", $a[2]);
- }
- else
- {
- return "Last digit must be '0' or '5'";
- }
- }
- else
- {
- return "Missing decimal point. Accepted format (x)xx.xx"
- }
- }
- else
- {
- return "Frequency value must be in the range 87.50 ... 108.00 of the format (x)xx.xx";
- }
- }
- else
- {
- return "Frequency value must be numeric in the range 87.50 ... 108.00 of the format (x)xx.xx";
- }
- }
- else
- {
- return "Frequency length must be 5 or 6 characters e.g. 89.50 or 108.00";
- }
+ if(length($a[2]) <= 6 and length($a[2]) >= 5) # Check the string length (x)xx.xx
+ {
+ if ( $a[2] =~ /^[0-9,.E]+$/ ) # Check if value is numeric
+ {
+ if(substr($a[2], -3, 1) eq '.') # Check for decimal point
+ {
+ if( $a[2] >= 87.50 and $a[2] <= 108.00) # Check if within the value range
+ {
+ my $lastDigit = substr($a[2], -1, 1);
+ if(($lastDigit eq "0") or ($lastDigit eq "5"))
+ {
+ my $frequency = $a[2];
+ $frequency =~ s/\.//; # Remove decimal point
+ YAMAHA_NP_SendCommand($hash, "".$frequency."<\/Freq><\/FM><\/Tuning><\/Play_Control><\/Tuner>", "tunerFMFrequency", $a[2]);
+ }
+ else
+ {
+ return "Last digit must be '0' or '5'";
+ }
+ }
+ else
+ {
+ return "Frequency value must be in the range 87.50 ... 108.00 of the format (x)xx.xx";
+ }
+ }
+ else
+ {
+ return "Missing decimal point. Accepted format (x)xx.xx";
+ }
+ }
+ else
+ {
+ return "Frequency value must be numeric in the range 87.50 ... 108.00 of the format (x)xx.xx";
+ }
+ }
+ else
+ {
+ return "Frequency length must be 5 or 6 characters e.g. 89.50 or 108.00";
+ }
}
else
{
diff --git a/fhem.cfg b/fhem.cfg
index 8c7cfd43e..90012cfb6 100644
--- a/fhem.cfg
+++ b/fhem.cfg
@@ -1,12 +1,23 @@
+attr global userattr cmdIcon devStateIcon devStateStyle icon sortby webCmd widgetOverride
+attr global autoload_undefined_devices 1
attr global logfile ./log/fhem-%Y-%m.log
attr global modpath .
+attr global motd SecurityCheck:\
+\
+WEB,WEBphone,WEBtablet has no basicAuth attribute.\
+telnetPort has no password/globalpassword attribute.\
+Running with root privileges.\
+Restart FHEM for a new check if the problem is fixed,\
+or set the global attribute motd to none to supress this message.\
+
attr global statefile ./log/fhem.save
+attr global updateInBackground 1
attr global verbose 3
-attr global updateInBackground
define telnetPort telnet 7072 global
define WEB FHEMWEB 8083 global
+attr WEB editConfig 1
define WEBphone FHEMWEB 8084 global
attr WEBphone stylesheetPrefix smallscreen
@@ -17,10 +28,13 @@ attr WEBtablet stylesheetPrefix touchpad
# Fake FileLog entry, to access the fhem log from FHEMWEB
define Logfile FileLog ./log/fhem-%Y-%m.log fakelog
+
define autocreate autocreate
attr autocreate filelog ./log/%NAME-%Y.log
define eventTypes eventTypes ./log/eventTypes.txt
# Disable this to avoid looking for new USB devices on startup
-define initialUsbCheck notify global:INITIALIZED usb create
+define initialUsbCheck notify global:INITIALIZED usb create
+
+define NP_test YAMAHA_NP 192.168.1.15 30 10