Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support line folding #4

Open
ducky64 opened this issue Nov 9, 2023 · 4 comments
Open

Support line folding #4

ducky64 opened this issue Nov 9, 2023 · 4 comments

Comments

@ducky64
Copy link
Contributor

ducky64 commented Nov 9, 2023

DESCRIPTION:This is a lo
 ng description
  that exists on a long line.

should be interpreted as

DESCRIPTION:This is a long description that exists on a long line.

per https://icalendar.org/iCalendar-RFC-5545/3-1-content-lines.html, where newline plus whitespace should effectively be discarded.

Currently, the parser tries to interpret these as VLINEs and errors out.

This gets generated by Google Calendar exports.

For anyone trying to just get something to work, a hack solution to discard the extra lines is:

diff --git a/src/vline.cpp b/src/vline.cpp
index 9f86607..81ff1ec 100644
--- a/src/vline.cpp
+++ b/src/vline.cpp
@@ -11,16 +11,18 @@
 namespace uICAL {
     VLine::VLine(const string& line) {
         if(line.empty()) {
+            this->name = string::none();
+            this->value = string::none();
             log_error("%s", "VLINE is empty");
-            throw ParseError("VLINE is empty");
         }

         size_t colon = line.find(":");
         size_t semicolon = line.find(";");

         if (colon == string::npos) {
+            this->name = string::none();
+            this->value = string::none();
             log_error("VLINE does not have a ':' \"%s\"", line.c_str());
-            throw ParseError(string("VLINE does not have a ':' \"") + line + "\"");
         }

         if (semicolon != string::npos && semicolon < colon) {

In general, the parsing is very strict, which would seem undesirable for embedded applications and deployments which should probably prioritize uptime and availability.

@DrJohannessen
Copy link

any update on that? i ran into the same pproblen, espacially the heavy use of throw.

@ducky64
Copy link
Contributor Author

ducky64 commented Apr 2, 2024

If you just need it to run and parse calendars, the above diff / patch is sufficient. It will truncate multiline entries. Tested on a ESP32-S3, not sure it will run on something much weaker.

Ultimately, I think this library's structure is too brittle (non-recoverable validation) for my application, I instead chose to offload processing to a external server running Python that has a more robust parser.

@DrJohannessen
Copy link

yeah, im building an e paper calendar, i also thought about that, but i dont think im giving up yet. i also saw there are some forks, but my cpp knowledge is not good enough to check if they acutally work / improve stuff, but certainly seems so.

@sourcesimian
Copy link
Owner

Thank you @ducky64, I'm not currently working in uICAL, but feel free to submit a pull request with new and passing tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants