MartinThoma / ics-parser

Automatically exported from code.google.com/p/ics-parser
48 stars 28 forks source link

Multiline Fields getting stripped spaces #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.  The following event block:
BEGIN:VEVENT
DTSTART;VALUE=DATE:20111104
DTEND;VALUE=DATE:20111105
SUMMARY:Photo Day
DESCRIPTION:8:45-12:00\nPlease make sure that students have their photo 
 forms and payments on the day of photo day that they can hand to the 
 photographer
LOCATION:individual photos will be taken in the Library and class photos 
 will be taken in The Art Room
UID:FA2ADBF1-1815-4F8F-9040-DD983DE10B4E
DTSTAMP:20120829T070843Z
TRANSP:TRANSPARENT
LAST-MODIFIED:20120828T142712Z
X-BUSYMAC-LASTMODBY:Administrator
END:VEVENT

What is the expected output? What do you see instead?
Expected output of description should be:
"8:45-12:00\nPlease make sure that students have their photo forms and payments 
on the day of photo day that they can hand to the photographer"

What I end up with:
"8:45-12:00\nPlease make sure that students have their photoforms and payments 
on the day of photo day that they can hand to thephotographer"

note no space between photo and forms and the and photographer

What version of the product are you using? On what operating system?
latest as of today, sorry.

Please provide any additional information below.

Original issue reported on code.google.com by brett.wa...@gmail.com on 30 Aug 2012 at 2:12

GoogleCodeExporter commented 9 years ago
As a quick workaround you can comment out the trim function on line 65 of 
class.iCalReader.php ... or perhaps change it to $line = rtrim($line);

Original comment by sfitchet2@gmail.com on 7 Oct 2012 at 8:33

GoogleCodeExporter commented 9 years ago
Take a look at this file. A couple of issues are addressed here:

- This allows specifying raw data as constructor method, be a complete string 
or an array of lines
- Contents are retrieved using file_get_contents(), instead of file: this 
allows more flexible parsing.
- Then, a regular expression with a lookahead is used to split string into 
lines (ln. 24): !(\r\n?|\n)(?=[^ ])!m. This means: a UNIX or Windows linebreak 
is a separator, unless followed by immediate space; do this for all lines.
- Then, the internal folding sequence is "unfolded" by removing "\n " (ln. 34). 
You can take a look at this article: 
http://tools.ietf.org/html/rfc2445#section-4.1

I'm pretty sure my change can easily be incorporated into your existing class. 
;)

Original comment by an...@angkacafe.com on 17 Oct 2012 at 2:20

Attachments:

olilesp commented 1 month ago

I'd like to reopen this ticket because I have the same problem and the two solutions above don't work. Commenting gives me incomprehensible characters and ltrim / rtrim creates spaces in words.

The comment file is no longer available.

Is an update possible?

Thank you