From 77037e7df87b45fa2a05faa101279c18a2875267 Mon Sep 17 00:00:00 2001 From: borisneubert <> Date: Sat, 11 Oct 2014 17:39:02 +0000 Subject: [PATCH] 57_Calendar: process continuation lines, get/set syntax checks git-svn-id: https://svn.fhem.de/fhem/trunk@6742 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/57_Calendar.pm | 38 +++++++++++++++++++++----------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 175dfd783..b39c5f6ae 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. + - change: 57_Calendar: process continuation lines, get/set syntax checks - bugfix: SYSMON: fix availability of cpu/kernel_max - bugfix: SYSMON: numeric check - change: 59_Weather: change icons for conditions 31, 34, 36 diff --git a/fhem/FHEM/57_Calendar.pm b/fhem/FHEM/57_Calendar.pm index 9c535aca0..d3eb463c5 100644 --- a/fhem/FHEM/57_Calendar.pm +++ b/fhem/FHEM/57_Calendar.pm @@ -39,8 +39,6 @@ package main; # http://forum.fhem.de/index.php?topic=18707.new # http://forum.fhem.de/index.php?topic=15827.new # -# Continuation lines are only partially honored, e.g. not for descriptions -# # Potential future extensions: add support for EXDATE # http://forum.fhem.de/index.php?topic=24485.new#new # @@ -81,7 +79,10 @@ sub addproperty { $key= $1; $parts= defined($3) ? $3 : ""; $parameter= defined($4) ? $4 : ""; + } else { + return; } + return unless($key); #main::Debug "-> key=\'$key\' parts=\'$parts\' parameter=\'$parameter\'"; if($key eq "EXDATE") { push @{$self->{properties}{exdates}}, $parameter; @@ -115,19 +116,19 @@ sub parseSub { while($ln<$#ical) { my $line= $ical[$ln]; chomp $line; - $line =~ s/[\x0D]//; # chomp will not remove the CR - #main::Debug "$ln: $line"; + $line =~ s/[\x0D]$//; # chomp will not remove the CR $ln++; - next if($line eq ""); # remove empty line - #### corrects line-wraps: if next line is starting with at least 2 spaces, join them - if ($ln<$#ical){ - my $line1= $ical[$ln]; - if ($line1 =~ s/^\s\s*//) { - $line.=$line1; - $ln++; - }; - }; - #### + # check for and handle continuation lines (4.1 on page 12) + while($ln<$#ical) { + my $line1= $ical[$ln]; + last unless($line1 =~ /^\s(.*)/); + $line.= $1; + chomp $line; + $line =~ s/[\x0D]$//; # chomp will not remove the CR + $ln++; + }; + #main::Debug "$ln: $line"; + next if($line eq ""); # ignore empty line last if($line =~ m/^END:.*$/); if($line =~ m/^BEGIN:(.*)$/) { my $entry= ICal::Entry->new($1); @@ -978,6 +979,7 @@ sub Calendar_Set($@) { my ($hash, @a) = @_; my $cmd= $a[1]; + $cmd= "?" unless($cmd); # usage check if((@a == 2) && ($a[1] eq "update")) { @@ -998,12 +1000,14 @@ sub Calendar_Get($@) { my ($hash, @a) = @_; - my $eventsObj= $hash->{fhem}{events}; my @events; my $cmd= $a[1]; - if(grep(/^$cmd$/, ("text","full","summary","location","alarm","start","end"))) { + $cmd= "?" unless($cmd); + + my @cmds2= qw/text full summary location alarm start end/; + if($cmd ~~ @cmds2) { return "argument is missing" if($#a < 2); my $reading= $a[2]; @@ -1049,7 +1053,7 @@ sub Calendar_Get($@) { return join(";", @uids); } else { - return "Unknown argument $cmd, choose one of text summary full find"; + return "Unknown argument $cmd, choose one of find text full summary location alarm start end"; } }