modolabs / Kurogo-Mobile-Web

Kurogo is a PHP framework for delivering high quality, data driven customizable content to a wide range of mobile devices. Its strengths lie in the customizable system that allows you to adapt content from a variety of sources and easily present that to mobile devices from feature phones, to early generation smart phones, to modern devices and tablets
http://kurogo.org
GNU Lesser General Public License v2.1
198 stars 99 forks source link

ICSDataParser Incorrectly Parses Content that Includes Semi-Colons #55

Closed chriscronbaugh closed 12 years ago

chriscronbaugh commented 12 years ago

I believe that ICSDataParser incorrectly parses a ICS file if a non-date/time line contains a semi-colon. For example, I have some multi-line "DESCRIPTION" tags that contain a semi-colon.

I get the following errors when this happens: Undefined offset: 1 in /GU/modolabs-Kurogo-Mobile-Web-e040489/lib/Calendar/ICSDataParser.php on line 54 Undefined offset: 2 in /GU/modolabs-Kurogo-Mobile-Web-e040489/lib/Calendar/ICSDataParser.php on line 54

I'm not 100% sure of this, but I believe the issue arises on line 48 of ICSDataParser.php, where there is an explode with a semi-colon as the delimiter. If I get to looking further into the issue before there is a response, I will make sure to post my findings here.

akinspe commented 12 years ago

Can you post a URL of the ics file you're having trouble with? or attach the file with the contents? That will help with addressing this issue

eebs commented 12 years ago

If you're getting errors on line 54, it means the preg_match on line 53 failed. As Pete said, seeing the ICS file will help us diagnose the issue, but regardless we will add some additional error handling to that section.

chriscronbaugh commented 12 years ago

Here is a link to download the file:

[edited to remove link]

eebs commented 12 years ago

The problem lies in the DESCRIPTION lines in your iCal file. iCal is organized into Content Lines, where each content line is ended with a line break, which is a CRLF sequence. Because the descriptions for your events contain line breaks, the ICS parser thinks the lines in your description are Content Lines, and attempts to parse them. The simplest fix is to remove the line breaks in your description lines, so they are one long line. That may not be possible however, if you would like to preserve the line breaks.

First let's tackle the issue of the description taking up more than one line. If you would like to keep this behavior, you must add a single whitespace character at the beginning of each description line that is not the first line.

For example the line:

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

Can be represented as:

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

Notice how there is a space a the beginning of each successive line. There are two spaces on the third line, as the second space is the space between the words 'description' and 'that'.

In order to preserve line breaks, you must add '\n' wherever you would like a line break.

A multiple line value of:

 Project XYZ Final Review
 Conference Room - 3B
 Come Prepared.

would be represented as:

 Project XYZ Final Review\nConference Room - 3B\nCome Prepared.

or if it were to be split to several lines it would be

 Project XYZ Final Review\n
  Conference Room - 3B\n
  Come Prepared.

I hope this helps, let us know if there's anything else we can help with.

chriscronbaugh commented 12 years ago

This definitely helps and I thank you for the help. I'll make sure to investigate an issue more next time.