Rakefire / jekyll-ical-tag

Pull ICS feed and provide a for-like loop of calendar events in jekyll's liquid tag
7 stars 6 forks source link

Undefined method error when a VEVENT component includes a DESCRIPTION with some IRIs #25

Closed fabacab closed 3 years ago

fabacab commented 3 years ago

Hi again. I noticed a new issue with certain iCalendar feeds that I'm having difficulty troubleshooting because of my lack of Ruby skill. The error is consistent and happens during a jekyll build for me:

Liquid Exception: undefined method `force_encoding' for #<Icalendar::Values::Array:0x00007fb0623e7528> in /_layouts/calendars.html
jekyll 3.9.0 | Error:  undefined method `force_encoding' for #<Icalendar::Values::Array:0x00007fb0623e7528>

I've attached a copy of the iCalendar file (serenoregis.ical.txt) causing the issue. It was sourced from an Italian Web site's event calendar feed.

The issue seems to be on line 69 of event.rb, where the description variable remains of type Icalendar::Values::Array despite its conversion to a string.

There are three VEVENT components in the attached copy of the feed, but only one of them (the last of the three) is causing the error. It's also worth noting that it's also the only VEVENT component with a URL in the DESCRIPTION property, triggering the regex to match URLs and thus the relevant description_urls method.

Despite tracing this down in this way, I'm unsure what a good resolution would be so I'm opening this issue to ask for your advice on how to patch.

rickychilcott commented 3 years ago

Thanks for the documentation and hunting this down. I’m refactoring a few things and finally building out a test suite to test against this and other feeds. I hope to have a better understanding of how to fix after that. Give me a day or two to get back to you.

fabacab commented 3 years ago

Give me a day or two to get back to you.

No rush. Let me know if there's any additional information I can offer.

rickychilcott commented 3 years ago

I think I fixed #25 by first checking if descriptions are an array, and if so, joining them with a new line character.

The exception is no longer raised @fabacab. Do you mind trying the latest (v1.2.5) to see if you're able to parse it correctly and you have the expected output?

Thanks for promoting this. I finally have a test suite as introduced in https://github.com/Rakefire/jekyll-ical-tag/commit/abbd080cc2a668b69f68332ad2f75340684e5fef This should make further regression testing (and refactoring) much easier.

fabacab commented 3 years ago

Thanks for getting around to this so quickly, @rickychilcott. While I don't get an error after updating the Gem to release v1.2.5, I'm not seeing the expected output. These are probably regressions so I'll record them individually as new issues for you momentarily.