47 Commits

Author SHA1 Message Date
Quentin Hibon
01142891a7 ical: use the VALUE parameter in DTSTART
According to RFC5545 3.3 (Property Value Data Types):

"If the value type of a property is one of the alternate valid types, then it
MUST be explicitly specified with the "VALUE" parameter."

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2018-05-10 14:03:29 +02:00
Lars Henriksen
c0644d5aaf Fix spelling of "frequency"
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-10-23 21:18:07 +02:00
Lukas Fleischer
ed6035afb1 Do not read past NUL character in ical_get_value()
Make sure we never read beyond the end of the buffer, even if the
terminating quote of a quoted string is missing.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-02-08 07:32:35 +01:00
Lukas Fleischer
e4e2e0eb20 Gracefully parse iCal parameters with colons
According to RFC 5545, iCalendar content lines can have optional
parameters, which can be quoted strings containing colons (":"). Make
sure that such colons are not interpreted as delimiters marking the
start of the value string.

Also, add a test case that covers this corner case.

Reported-by: Håkan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-02-07 21:54:05 +01:00
Lukas Fleischer
9f6678bc49 Update copyright ranges
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-01-12 08:40:30 +01:00
Lukas Fleischer
07954626c6 Support format strings when dumping imported items
In commit 3eae7ce (Add --list-imported command line option, 2016-01-12),
we added an option to print the hashes of imported items to stdout.
Extend this command line option such that it dumps the items using the
specified formatting strings. With the new behavior it is, for example,
easier to check items for import errors.

Also, rename the option from --list-imported to --dump-imported (it is
not part of any official release yet so we do not need to care about
backwards compatibility).

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-02-11 18:33:57 +01:00
Lukas Fleischer
978d24a9d2 Update copyright ranges
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-30 11:21:53 +01:00
Lukas Fleischer
e3ac5542aa Support todo items with an undefined priority
In addition to priorities 1-9, support todo items without any specific
priority, internally represented by priority 0.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-18 18:08:45 +01:00
Lukas Fleischer
beea88e5fe Use a separate field for the completed status
Add a new field that indicates whether a todo item is completed or not
instead of encoding completed todo items by negative priorities.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-18 18:08:34 +01:00
Lukas Fleischer
caee34449c Export item UIDs upon request
Add a new --export-uid command line option that adds each item's hash to
the UID property when exporting.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-15 18:25:05 +01:00
Lukas Fleischer
2994ea7003 ical: Handle items without an end date gracefully
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-13 18:15:59 +01:00
Lukas Fleischer
2c4a650dbe ical: Refactor item date/time parser
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-13 18:06:22 +01:00
Lukas Fleischer
56f615ffe2 Reimplement ical_unformat_line() using dynamic strings
Use the new dynamic string utility functions instead of relying on a
fixed-size buffer.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-13 17:39:44 +01:00
Lukas Fleischer
5f344e177f ical: Export completed todo items properly
Do not skip completed todo items when exporting to an iCal file.
Instead, mark them as "STATUS:COMPLETED".

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-13 17:39:44 +01:00
Lukas Fleischer
0053dd5cdc ical: Honor completed status of todo items
When importing todo items from an iCal file, mark completed items as
completed.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-13 17:39:44 +01:00
Lukas Fleischer
3eae7ce828 Add --list-imported command line option
When this option is used together with -i/--import, the object
identifiers of imported objects are printed to stdout.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-13 17:39:44 +01:00
Lukas Fleischer
90e6c61252 ical.c: Small refactoring
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2015-02-25 16:19:14 +01:00
Lukas Fleischer
0145ba12ec Use time_t instead of long in several places
Start converting some variables and return values to store times from
long to time_t.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2015-02-24 13:57:47 +01:00
Lukas Fleischer
329ef1c22a ical.c: Reduce nesting depth
Refactor the iCal parser to reduce nesting depth.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2015-02-24 11:56:55 +01:00
Lukas Fleischer
52779d2ec6 Introduce starts_with() and starts_with_ci()
Create user-defined functions to check whether a string contains a
certain prefix instead of messing around with strncmp() and
strncasecmp().

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2015-02-24 11:17:38 +01:00
Lukas Fleischer
1ea97795be Add support for UTC times in iCal imports
According to the iCal standard (4.3.12 Time):

    UTC time, or absolute time, is identified by a LATIN CAPITAL LETTER
    Z suffix character (US-ASCII decimal 90), the UTC designator,
    appended to the time value.

Parse such time values properly when importing iCal files.

Fixes GitHub issue #3.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2015-02-23 10:46:16 +01:00
Lukas Fleischer
9ef427693b Update copyright ranges
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2015-02-07 11:42:20 +01:00
Lukas Fleischer
76f151ff37 Correctly parse all types of iCal durations
This was supposed to be fixed in 6ca2535 (ical.c: Simplify and fix
ical_durtime2long(), 2014-07-28) but some cases were not covered.

Reported-by: Håkan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-18 15:18:11 +02:00
Lukas Fleischer
f3fe3c818c Gracefully handle all day events in iCal imports
Do not create two events when importing an event that lasts an entire
day.

Reported-by: Jörn Tillmanns <tillmanns@tuxzone.org>
Reported-by: Håkan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-18 12:20:09 +02:00
Lukas Fleischer
bcc820ea74 Handle CRLF line endings in iCal files
RFC 2445 mentions that CRLF line endings may be used in iCal files.
Handle them properly when importing.

Reported-by: Håkan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-18 11:37:41 +02:00
Lukas Fleischer
6aa21da8c6 ical.c: Parse multiple exception rules properly
There can be multiple EXDATE lines per event. Parse them correctly
instead of making the last line overwrite the previous ones.

Reported-by: Håkan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-28 12:43:00 +02:00
Lukas Fleischer
6ca2535f5e ical.c: Simplify and fix ical_durtime2long()
Correctly parse all types of durations. Before this change, durations
without an hour or minute component were not parsed properly.

Reported-by: Håkan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-28 12:43:00 +02:00
Lukas Fleischer
936d5f139f ical.c: Remove newlines from item summaries
Newline characters are not allowed in calcurse item descriptions.
Replace any newlines in iCal summary lines with spaces.

Fixes GitHub issue #6.

Reported-by: Jonathan McCrohan <jmccrohan@gmail.com>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-08 13:14:08 +02:00
Lukas Fleischer
694d28eb78 Use tabs instead of spaces for indentation
This completes our switch to the Linux kernel coding style. Note that we
still use deeply nested constructs at some places which need to be fixed
up later.

Converted using the `Lindent` script from the Linux kernel code base,
along with some manual fixes.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-04-14 00:19:01 +02:00
Lukas Fleischer
a363cb9b91 Fix braces in if-else statements
From the Linux kernel coding guidelines:

    Do not unnecessarily use braces where a single statement will do.
    [...] This does not apply if one branch of a conditional statement
    is a single statement. Use braces in both branches.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-17 09:19:04 +01:00
Lukas Fleischer
b30ccc6319 Merge branch 'maint' 2013-02-04 20:11:58 +01:00
Lukas Fleischer
a7944d335e Update copyright ranges
Add 2013 to the copyright range for all source and documentation files.

Reported-by: Frederic Culot <frederic@culot.org>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-04 20:10:14 +01:00
Lukas Fleischer
de73d96188 Use strncasecmp() for case-insensitive comparison
Instead of converting everything to upper case and then using strncmp(),
use strncasecmp() which does case-insensitive comparison out of the box.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-01-30 15:42:08 +01:00
Lukas Fleischer
64662ff2ce Fix two enumeration types in function signatures
Spotted with clang and "-Wconversion".

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-12-06 20:41:19 +01:00
Lukas Fleischer
8375e9a51b Use integers rather than floats everywhere
We don't need floating point precision if results are casted back to
integer. Instead, rearrange operations and do the integer division after
the multiplication.

Version numbers are terminating decimals anyway and can be stored using
two integers without losing any information.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-10 11:58:15 +02:00
Lukas Fleischer
cfd8ede2b3 Switch to Linux kernel coding style
Convert our code base to adhere to Linux kernel coding style using
Lindent, with the following exceptions:

* Use spaces, instead of tabs, for indentation.
* Use 2-character indentations (instead of 8 characters).

Rationale: We currently have too much levels of indentation. Using
8-character tabs would make huge code parts unreadable. These need to be
cleaned up before we can switch to 8 characters.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-21 10:13:05 +02:00
Lukas Fleischer
6da787a5cc Declare several parameters/variables constant
Add the "const" keyword to parameters and variables that are never
modified. Most of these were spotted by "-Wwrite-strings".

We cast the second parameter to execvp() explicitly as it expects a
"char *const[]" where it should expect a "const char *const[]"
(according to the documentation, this is due to compatibility reasons).
This should be changed once we come up with a better solution.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-08 21:50:05 +02:00
Lukas Fleischer
315b33540a Mark several functions static
These are not needed outside of the corresponding compilation units.
Spotted with "-Wmissing-prototypes".

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-20 23:10:56 +02:00
Lukas Fleischer
d31cda5424 Revert a bunch of strncmp() conversions
All strncmp() usages were replaced by (evidently) equivalent strcmp()
invocations in commit 2c9499bf272e06a62902711c6c20621ef3f80e64. However,
some of the strncmp() calls were perfectly justified and we actually
broke iCal import and "C-"-style key bindings by converting them to
strcmp(). Fix this by reverting all affected conversions.

Reported-by: Baptiste Jonglez <baptiste@jonglez.org>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-03-30 15:50:27 +02:00
Lukas Fleischer
c9aff6d213 Update copyright ranges
Add 2012 to the copyright range for all source and documentation files.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-03-26 14:38:16 +02:00
Lukas Fleischer
0f4b45e624 Get rid of string structures
These were only used to construct constant strings with additional
length fields. However, we can just use standard constant character
arrays instead and let the compiler calculate the string length.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-03-12 20:36:22 +01:00
Lukas Fleischer
2c9499bf27 Use strcmp() instead of strncmp()
strncmp() isn't intended to be a secure strcmp() replacement, it is
designed to be used if you want to compare the first n characters of two
strings. Since we always compare character pointers with string
literals, switch to using strcmp() everywhere.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-03-12 20:36:22 +01:00
Lukas Fleischer
8892bb3625 Remove all usages of bzero() and bcopy()
The bzero() and bcopy() functions are deprecated and were removed from
the POSIX standard in IEEE Std. 1003.1-2008. Remove all usages of
bzero()/bcopy() and replace them by appropriate memset()/memmove()
calls.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-02-19 01:41:01 +01:00
Lukas Fleischer
c17b535a33 Fix up strncat() usage
The last argument to strncat() should not be the total buffer length; it
should be the space remaining:

    The strncat() function shall append not more than n bytes (a null
    byte and bytes that follow it are not appended) from the array
    pointed to by s2 to the end of the string pointed to by s1. The
    initial byte of s2 overwrites the null byte at the end of s1. A
    terminating null byte is always appended to the result.

This patch fixes a couple of potential buffer overflow vulnerabilities.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-02-18 16:00:18 +01:00
Lukas Fleischer
fb58416f45 Don't chomp on error in ical_readline_init()
Skip the newline check if fgets() returns a NULL string. Fixes another
warning seen with "-Wunused-result".

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-02-18 16:00:18 +01:00
Lukas Fleischer
a79a33e8f4 Split note file generation into separate function
We currently use this in one place only but might reuse this a couple of
times later (when migrating to libical).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-01-17 00:52:39 +01:00
Lukas Fleischer
5dc443fc3d Break out different import/export formats
Extract iCal and pcal import/export routines into separate files. This
reduces complexity of the super huge "io.c" source file and makes it
easier to follow changes that affect the iCal and pcal routines only
(commits affecting both formats are very uncommon).

Before:

    $ wc -l src/io.c
    2938 src/io.c

After:

    $ wc -l src/{io,ical,pcal}.c
     1445 src/io.c
     1263 src/ical.c
      317 src/pcal.c
     3025 total

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-01-07 12:41:51 +01:00