"Return a new buffer containing the unfolded contents of a buffer.
Folding is the iCalendar way of wrapping long lines. In the
created buffer all occurrences of CR LF BLANK are replaced by the
-empty string. Argument FOLDED-ICAL-BUFFER is the unfolded input
+empty string. Argument FOLDED-ICAL-BUFFER is the folded input
buffer."
(let ((unfolded-buffer (get-buffer-create " *icalendar-work*")))
(save-current-buffer
(set-buffer unfolded-buffer)
(erase-buffer)
(insert-buffer-substring folded-ical-buffer)
+ (icalendar--clean-up-line-endings)
(goto-char (point-min))
(while (re-search-forward "\r?\n[ \t]" nil t)
(replace-match "" nil nil)))
unfolded-buffer))
+(defun icalendar--clean-up-line-endings ()
+ "Replace DOS- and MAC-like line endings with unix line endings.
+All occurrences of (CR LF) and (LF CF) are replaced with LF in
+the current buffer. This is necessary in buffers which contain a
+mix of different line endings."
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward "\r\n\\|\n\r" nil t)
+ (replace-match "\n" nil nil))))
+
(defsubst icalendar--rris (regexp rep string &optional fixedcase literal)
"Replace regular expression in string.
Pass arguments REGEXP REP STRING FIXEDCASE LITERAL to
Class: PUBLIC
UID: 040000008200E00074C5B7101A82E0080000000020FFAED0CFEFCC01000000000000000010000000575268034ECDB649A15349B1BF240F15
" nil)
+
+ ;; 2015-12-05, mixed line endings and empty lines, see Bug#22092.
+ (icalendar-tests--test-import
+ "BEGIN:VCALENDAR\r
+PRODID:-//www.norwegian.no//iCalendar MIMEDIR//EN\r
+VERSION:2.0\r
+METHOD:REQUEST\r
+BEGIN:VEVENT\r
+UID:RFCALITEM1\r
+SEQUENCE:1512040950\r
+DTSTAMP:20141204T095043Z\r
+ORGANIZER:noreply@norwegian.no\r
+DTSTART:20141208T173000Z\r
+
+DTEND:20141208T215500Z\r
+
+LOCATION:Stavanger-Sola\r
+
+DESCRIPTION:Fly med Norwegian, reservasjon. Fra Stavanger til Tromsø 8. des 2014 18:30, DY545Fly med Norwegian, reservasjon . Fra Stavanger til Tromsø 8. des 2014 21:00, DY390\r
+
+X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\"><html><head><META NAME=\"Generator\" CONTENT=\"MS Exchange Server version 08.00.0681.000\"><title></title></head><body><b><font face=\"Calibri\" size=\"3\">Reisereferanse</p></body></html>
+SUMMARY:Norwegian til Tromsoe-Langnes -\r
+
+CATEGORIES:Appointment\r
+
+
+PRIORITY:5\r
+
+CLASS:PUBLIC\r
+
+TRANSP:OPAQUE\r
+END:VEVENT\r
+END:VCALENDAR
+"
+"&2014/12/8 18:30-22:55 Norwegian til Tromsoe-Langnes -
+ Desc: Fly med Norwegian, reservasjon. Fra Stavanger til Tromsø 8. des 2014 18:30, DY545Fly med Norwegian, reservasjon . Fra Stavanger til Tromsø 8. des 2014 21:00, DY390
+ Location: Stavanger-Sola
+ Organizer: noreply@norwegian.no
+ Class: PUBLIC
+ UID: RFCALITEM1
+"
+"&8/12/2014 18:30-22:55 Norwegian til Tromsoe-Langnes -
+ Desc: Fly med Norwegian, reservasjon. Fra Stavanger til Tromsø 8. des 2014 18:30, DY545Fly med Norwegian, reservasjon . Fra Stavanger til Tromsø 8. des 2014 21:00, DY390
+ Location: Stavanger-Sola
+ Organizer: noreply@norwegian.no
+ Class: PUBLIC
+ UID: RFCALITEM1
+"
+"&12/8/2014 18:30-22:55 Norwegian til Tromsoe-Langnes -
+ Desc: Fly med Norwegian, reservasjon. Fra Stavanger til Tromsø 8. des 2014 18:30, DY545Fly med Norwegian, reservasjon . Fra Stavanger til Tromsø 8. des 2014 21:00, DY390
+ Location: Stavanger-Sola
+ Organizer: noreply@norwegian.no
+ Class: PUBLIC
+ UID: RFCALITEM1
+"
)
+ )
(provide 'icalendar-tests)
;;; icalendar-tests.el ends here