kopia lustrzana https://github.com/collective/icalendar
				
				
				
			Merge remote-tracking branch 'jkiang13/skip-event-with-invalid-line'
						commit
						2e9ce70fe5
					
				|  | @ -302,7 +302,19 @@ class Component(CaselessDict): | ||||||
|         for line in Contentlines.from_ical(st):  # raw parsing |         for line in Contentlines.from_ical(st):  # raw parsing | ||||||
|             if not line: |             if not line: | ||||||
|                 continue |                 continue | ||||||
|             name, params, vals = line.parts() | 
 | ||||||
|  |             try: | ||||||
|  |                 name, params, vals = line.parts() | ||||||
|  |             except ValueError: | ||||||
|  |                 # if unable to parse a line within a component | ||||||
|  |                 # that ignores exceptions, mark the component | ||||||
|  |                 # as broken and skip the line. otherwise raise. | ||||||
|  |                 component = stack[-1] if stack else None | ||||||
|  |                 if not component or not component.ignore_exceptions: | ||||||
|  |                     raise | ||||||
|  |                 component.is_broken = True | ||||||
|  |                 continue | ||||||
|  | 
 | ||||||
|             uname = name.upper() |             uname = name.upper() | ||||||
|             # check for start of component |             # check for start of component | ||||||
|             if uname == 'BEGIN': |             if uname == 'BEGIN': | ||||||
|  |  | ||||||
|  | @ -1,41 +0,0 @@ | ||||||
| BEGIN:VEVENT |  | ||||||
| DTSTART:20130927T130000Z |  | ||||||
| DTEND:20130927T140000Z |  | ||||||
| DTSTAMP:20131107T004757Z |  | ||||||
| ORGANIZER;CN=gxxxxxxxn@nxx.fr:mailto:gxxxxxn@nxx.fr |  | ||||||
| UID:040000008200E00074C5B7101A82E00800000000A0F3321606B6CE01000000000000000 |  | ||||||
|  010000000F09F33F0E8ED4C44B99F6027ACF588D0 |  | ||||||
| ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;CN=St |  | ||||||
|  eve Bxxxxxx;X-NUM-GUESTS=0:mailto:sxxxxxt@nxx.fr |  | ||||||
| ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=Boris |  | ||||||
|  Hxxxxx;X-NUM-GUESTS=0:mailto:bxxxxxxk@vxxxxxxxx.com |  | ||||||
| CREATED:20130920T113409Z |  | ||||||
| DESCRIPTION:Quand : vendredi 27 septembre 2013 15:00-16:00 (UTC+01:00) Brux |  | ||||||
|  elles\, Copenhague\, Madrid\, Paris.\nEmplacement : Conf-Call - 01 xx xx xx |  | ||||||
|   xx\n\nRemarque : le décalage GMT ci-dessus ne tient pas compte des réglage |  | ||||||
|  s de l'heure d'été.\n\n*~*~*~*~*~*~*~*~*~*\n\nComme convenu à l’instant par |  | ||||||
|   e-mail\n |  | ||||||
| LAST-MODIFIED:20130920T115104Z |  | ||||||
| LOCATION:Conf-Call - 01 xx xx xx xx |  | ||||||
| SEQUENCE:0 |  | ||||||
| STATUS:CONFIRMED |  | ||||||
| SUMMARY:Nxx - Réunion lancement PxxxxxxT |  | ||||||
| TRANSP:OPAQUE |  | ||||||
| X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//E |  | ||||||
|  N">\n<HTML>\n<HEAD>\n<META NAME="Generator" CONTENT="MS Exchange Server ver |  | ||||||
|  sion 08.00.0681.000">\n<TITLE></TITLE>\n</HEAD>\n<BODY>\n<!-- Converted fro |  | ||||||
|  m text/rtf format -->\n\n<P DIR=LTR><SPAN LANG="fr"><FONT FACE="Calibri">Qu |  | ||||||
|  and : vendredi 27 septembre 2013 15:00-16:00 (UTC+01:00) Bruxelles\, Copenh |  | ||||||
|  ague\, Madrid\, Paris.</FONT></SPAN></P>\n\n<P DIR=LTR><SPAN LANG="fr"><FON |  | ||||||
|  T FACE="Calibri">Emplacement : Conf-Call - 01 xx xx xx xx</FONT></SPAN></P> |  | ||||||
|  \n\n<P DIR=LTR><SPAN LANG="fr"><FONT FACE="Calibri">Remarque : le décalage |  | ||||||
|  GMT ci-dessus ne tient pas compte des réglages de l'heure d'été.</FONT></SP |  | ||||||
|  AN></P>\n\n<P DIR=LTR><SPAN LANG="fr"><FONT FACE="Calibri">*~*~*~*~*~*~*~*~ |  | ||||||
|  *~*</FONT></SPAN></P>\n\n<P DIR=LTR><SPAN LANG="fr"><FONT FACE="Calibri">Co |  | ||||||
|  mme convenu à l’instant par e-mail</FONT></SPAN><SPAN LANG="fr"></SPAN></P> |  | ||||||
|  \n\n</BODY>\n</HTML> |  | ||||||
| X-MICROSOFT-CDO-BUSYSTATUS:TENTATIVE |  | ||||||
| X-MICROSOFT-CDO-IMPORTANCE:1 |  | ||||||
| X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY |  | ||||||
| X |  | ||||||
| END:VEVENT |  | ||||||
|  | @ -180,6 +180,50 @@ END:VCALENDAR""" | ||||||
|         org_cn = cal.walk('VEVENT')[0]['ORGANIZER'].params['CN'] |         org_cn = cal.walk('VEVENT')[0]['ORGANIZER'].params['CN'] | ||||||
|         self.assertEqual(org_cn, u'acme, ädmin') |         self.assertEqual(org_cn, u'acme, ädmin') | ||||||
| 
 | 
 | ||||||
|  |     def test_issue_104__ignore_exceptions(self): | ||||||
|  |         """ | ||||||
|  |         Issue #104 - line parsing error in a VEVENT | ||||||
|  |         (which has ignore_exceptions). Should mark the event broken | ||||||
|  |         but not raise an exception. | ||||||
|  |         https://github.com/collective/icalendar/issues/104 | ||||||
|  |         """ | ||||||
|  |         ical_str = """ | ||||||
|  | BEGIN:VEVENT | ||||||
|  | DTSTART:20140401T000000Z | ||||||
|  | DTEND:20140401T010000Z | ||||||
|  | DTSTAMP:20140401T000000Z | ||||||
|  | SUMMARY:Broken Eevnt | ||||||
|  | CLASS:PUBLIC | ||||||
|  | STATUS:CONFIRMED | ||||||
|  | TRANSP:OPAQUE | ||||||
|  | X | ||||||
|  | END:VEVENT""" | ||||||
|  |         event = icalendar.Calendar.from_ical(ical_str) | ||||||
|  |         self.assertTrue(isinstance(event, icalendar.Event)) | ||||||
|  |         self.assertTrue(event.is_broken) | ||||||
|  | 
 | ||||||
|  |     def test_issue_104__no_ignore_exceptions(self): | ||||||
|  |         """ | ||||||
|  |         Issue #104 - line parsing error in a VCALENDAR | ||||||
|  |         (which doesn't have ignore_exceptions). Should raise an exception. | ||||||
|  |         """ | ||||||
|  |         ical_str = """BEGIN:VCALENDAR | ||||||
|  | VERSION:2.0 | ||||||
|  | METHOD:PUBLISH | ||||||
|  | BEGIN:VEVENT | ||||||
|  | DTSTART:20140401T000000Z | ||||||
|  | DTEND:20140401T010000Z | ||||||
|  | DTSTAMP:20140401T000000Z | ||||||
|  | SUMMARY:Broken Eevnt | ||||||
|  | CLASS:PUBLIC | ||||||
|  | STATUS:CONFIRMED | ||||||
|  | TRANSP:OPAQUE | ||||||
|  | END:VEVENT | ||||||
|  | X | ||||||
|  | END:VCALENDAR""" | ||||||
|  |         with self.assertRaises(ValueError): | ||||||
|  |             icalendar.Calendar.from_ical(ical_str) | ||||||
|  | 
 | ||||||
|     def test_issue_112(self): |     def test_issue_112(self): | ||||||
|         """Issue #112 - No timezone info on EXDATE |         """Issue #112 - No timezone info on EXDATE | ||||||
|         https://github.com/collective/icalendar/issues/112 |         https://github.com/collective/icalendar/issues/112 | ||||||
|  | @ -206,18 +250,6 @@ END:VCALENDAR""" | ||||||
| 
 | 
 | ||||||
|             self.assertEqual(event['exdate'][0].dts[0].dt.tzname(), 'EDT') |             self.assertEqual(event['exdate'][0].dts[0].dt.tzname(), 'EDT') | ||||||
| 
 | 
 | ||||||
|     def test_issue_114(self): |  | ||||||
|         """Issue #114/#115 - invalid line in event breaks the parser |  | ||||||
|         https://github.com/collective/icalendar/issues/114 |  | ||||||
|         """ |  | ||||||
| 
 |  | ||||||
|         directory = os.path.dirname(__file__) |  | ||||||
|         ics = open(os.path.join(directory, 'issue_114_invalid_line.ics'), 'rb') |  | ||||||
|         with self.assertRaises(ValueError): |  | ||||||
|             cal = icalendar.Calendar.from_ical(ics.read()) |  | ||||||
|             cal  # pep 8 |  | ||||||
|         ics.close() |  | ||||||
| 
 |  | ||||||
|     def test_issue_116(self): |     def test_issue_116(self): | ||||||
|         """Issue #116/#117 - How to add 'X-APPLE-STRUCTURED-LOCATION' |         """Issue #116/#117 - How to add 'X-APPLE-STRUCTURED-LOCATION' | ||||||
|         """ |         """ | ||||||
|  |  | ||||||
		Ładowanie…
	
		Reference in New Issue
	
	 Johannes Raggam
						Johannes Raggam