This is an automated email from the ASF dual-hosted git repository.

chibenwa pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
     new 63b0a785ec [FIX] ICS parsing: lower expectations for a more reliable 
parsing
63b0a785ec is described below

commit 63b0a785ec36cc7e6151fdf62b4c27cb77ccc4c5
Author: Benoit TELLIER <[email protected]>
AuthorDate: Wed Sep 9 14:53:07 2026 +0200

    [FIX] ICS parsing: lower expectations for a more reliable parsing
---
 .../transport/mailets/model/ICALAttributeDTO.java  |  9 +++--
 .../mailets/model/ICALAttributeDTOTest.java        | 41 ++++++++++++++++++++++
 .../ics/meeting_with_invalid_dtstamp_tzid.ics      | 32 +++++++++++++++++
 .../meeting_with_invalid_recurrence_id_tzid.ics    | 33 +++++++++++++++++
 4 files changed, 110 insertions(+), 5 deletions(-)

diff --git 
a/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/model/ICALAttributeDTO.java
 
b/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/model/ICALAttributeDTO.java
index 2947f772fe..1e7281e4cb 100644
--- 
a/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/model/ICALAttributeDTO.java
+++ 
b/mailet/icalendar/src/main/java/org/apache/james/transport/mailets/model/ICALAttributeDTO.java
@@ -33,7 +33,6 @@ import com.google.common.base.Preconditions;
 import net.fortuna.ical4j.model.Calendar;
 import net.fortuna.ical4j.model.Property;
 import net.fortuna.ical4j.model.component.VEvent;
-import net.fortuna.ical4j.model.property.DtStamp;
 import net.fortuna.ical4j.model.property.Uid;
 
 public class ICALAttributeDTO {
@@ -66,14 +65,14 @@ public class ICALAttributeDTO {
         }
 
         private Optional<String> optionalOf(Property property) {
-            return Optional.ofNullable(property).map(Property::getValue);
+            return Optional.ofNullable(property).flatMap(this::safeValue);
         }
 
-        private Optional<String> safeValue(DtStamp dtStamp) {
+        private Optional<String> safeValue(Property property) {
             try {
-                return Optional.ofNullable(dtStamp.getValue());
+                return Optional.ofNullable(property.getValue());
             } catch (Exception e) {
-                LOGGER.warn("Ignoring non RFC-5545 compliant DTSTAMP value", 
e);
+                LOGGER.warn("Ignoring non RFC-5545 compliant {} value", 
property.getName(), e);
                 return Optional.empty();
             }
         }
diff --git 
a/mailet/icalendar/src/test/java/org/apache/james/transport/mailets/model/ICALAttributeDTOTest.java
 
b/mailet/icalendar/src/test/java/org/apache/james/transport/mailets/model/ICALAttributeDTOTest.java
index cab15c36e2..8a7477c90f 100644
--- 
a/mailet/icalendar/src/test/java/org/apache/james/transport/mailets/model/ICALAttributeDTOTest.java
+++ 
b/mailet/icalendar/src/test/java/org/apache/james/transport/mailets/model/ICALAttributeDTOTest.java
@@ -124,6 +124,47 @@ class ICALAttributeDTOTest {
         assertThat(ical.getDtstamp()).isEmpty();
     }
 
+    @Test
+    void dtoShouldIgnoreDtStampWithInvalidTzId() throws Exception {
+        byte[] ics = 
ClassLoaderUtils.getSystemResourceAsByteArray("ics/meeting_with_invalid_dtstamp_tzid.ics");
+        Calendar calendar = new CalendarBuilder().build(new 
ByteArrayInputStream(ics));
+
+        MailAddress recipient = MailAddressFixture.ANY_AT_JAMES;
+        MailAddress sender = MailAddressFixture.OTHER_AT_JAMES;
+        ICALAttributeDTO ical = ICALAttributeDTO.builder()
+            .from(calendar, ics)
+            .sender(sender)
+            .recipient(recipient)
+            .replyTo(sender);
+
+        SoftAssertions.assertSoftly(softly -> {
+            softly.assertThat(ical.getDtstamp()).isEmpty();
+            softly.assertThat(ical.getMethod()).contains("REQUEST");
+            softly.assertThat(ical.getSequence()).isEqualTo("0");
+        });
+    }
+
+    @Test
+    void dtoShouldIgnoreRecurrenceIdWithInvalidTzId() throws Exception {
+        byte[] ics = 
ClassLoaderUtils.getSystemResourceAsByteArray("ics/meeting_with_invalid_recurrence_id_tzid.ics");
+        Calendar calendar = new CalendarBuilder().build(new 
ByteArrayInputStream(ics));
+
+        MailAddress recipient = MailAddressFixture.ANY_AT_JAMES;
+        MailAddress sender = MailAddressFixture.OTHER_AT_JAMES;
+        ICALAttributeDTO ical = ICALAttributeDTO.builder()
+            .from(calendar, ics)
+            .sender(sender)
+            .recipient(recipient)
+            .replyTo(sender);
+
+        SoftAssertions.assertSoftly(softly -> {
+            softly.assertThat(ical.getRecurrenceId()).isEmpty();
+            softly.assertThat(ical.getDtstamp()).contains("20170106T115036Z");
+            softly.assertThat(ical.getMethod()).contains("REQUEST");
+            softly.assertThat(ical.getSequence()).isEqualTo("0");
+        });
+    }
+
     @Test
     void buildShouldSetDefaultValueWhenCalendarWithoutSequence() throws 
Exception {
         byte[] ics = 
ClassLoaderUtils.getSystemResourceAsByteArray("ics/meeting_without_sequence.ics");
diff --git 
a/mailet/icalendar/src/test/resources/ics/meeting_with_invalid_dtstamp_tzid.ics 
b/mailet/icalendar/src/test/resources/ics/meeting_with_invalid_dtstamp_tzid.ics
new file mode 100644
index 0000000000..89f6112498
--- /dev/null
+++ 
b/mailet/icalendar/src/test/resources/ics/meeting_with_invalid_dtstamp_tzid.ics
@@ -0,0 +1,32 @@
+BEGIN:VCALENDAR
+PRODID:-//Aliasource Groupe LINAGORA//OBM Calendar 3.2.1-rc2//FR
+CALSCALE:GREGORIAN
+X-OBM-TIME:1483703436
+VERSION:2.0
+METHOD:REQUEST
+BEGIN:VEVENT
+CREATED:20170106T115035Z
+LAST-MODIFIED:20170106T115036Z
+DTSTAMP;TZID=Invalid/Zone:20170106T115036
+DTSTART:20170111T090000Z
+DURATION:PT1H30M
+TRANSP:OPAQUE
+SEQUENCE:0
+SUMMARY:Sprint planning #23
+DESCRIPTION:
+CLASS:PUBLIC
+PRIORITY:5
+ORGANIZER;X-OBM-ID=128;CN=Raphael OUAZANA:MAILTO:[email protected]
+X-OBM-DOMAIN:linagora.com
+X-OBM-DOMAIN-UUID:02874f7c-d10e-102f-acda-0015176f7922
+LOCATION:Hangout
+CATEGORIES:
+X-OBM-COLOR:
+UID:f1514f44bf39311568d640727cff54e819573448d09d2e5677987ff29caa01a9e047fe
+ b2aab16e43439a608f28671ab7c10e754ce92be513f8e04ae9ff15e65a9819cf285a6962bc
+ATTENDEE;CUTYPE=INDIVIDUAL;RSVP=TRUE;CN=Matthieu EXT_BAECHLER;PARTSTAT=NEE
+ DS-ACTION;X-OBM-ID=302:MAILTO:[email protected]
+ATTENDEE;CUTYPE=INDIVIDUAL;RSVP=TRUE;CN=Benoît TELLIER;PARTSTAT=NEEDS-ACTI
+ ON;X-OBM-ID=623:MAILTO:[email protected]
+END:VEVENT
+END:VCALENDAR
diff --git 
a/mailet/icalendar/src/test/resources/ics/meeting_with_invalid_recurrence_id_tzid.ics
 
b/mailet/icalendar/src/test/resources/ics/meeting_with_invalid_recurrence_id_tzid.ics
new file mode 100644
index 0000000000..0101c6f90f
--- /dev/null
+++ 
b/mailet/icalendar/src/test/resources/ics/meeting_with_invalid_recurrence_id_tzid.ics
@@ -0,0 +1,33 @@
+BEGIN:VCALENDAR
+PRODID:-//Aliasource Groupe LINAGORA//OBM Calendar 3.2.1-rc2//FR
+CALSCALE:GREGORIAN
+X-OBM-TIME:1483703436
+VERSION:2.0
+METHOD:REQUEST
+BEGIN:VEVENT
+CREATED:20170106T115035Z
+LAST-MODIFIED:20170106T115036Z
+DTSTAMP:20170106T115036Z
+DTSTART:20170111T090000Z
+RECURRENCE-ID;TZID=Invalid/Zone:20170111T090000
+DURATION:PT1H30M
+TRANSP:OPAQUE
+SEQUENCE:0
+SUMMARY:Sprint planning #23
+DESCRIPTION:
+CLASS:PUBLIC
+PRIORITY:5
+ORGANIZER;X-OBM-ID=128;CN=Raphael OUAZANA:MAILTO:[email protected]
+X-OBM-DOMAIN:linagora.com
+X-OBM-DOMAIN-UUID:02874f7c-d10e-102f-acda-0015176f7922
+LOCATION:Hangout
+CATEGORIES:
+X-OBM-COLOR:
+UID:f1514f44bf39311568d640727cff54e819573448d09d2e5677987ff29caa01a9e047fe
+ b2aab16e43439a608f28671ab7c10e754ce92be513f8e04ae9ff15e65a9819cf285a6962bc
+ATTENDEE;CUTYPE=INDIVIDUAL;RSVP=TRUE;CN=Matthieu EXT_BAECHLER;PARTSTAT=NEE
+ DS-ACTION;X-OBM-ID=302:MAILTO:[email protected]
+ATTENDEE;CUTYPE=INDIVIDUAL;RSVP=TRUE;CN=Benoît TELLIER;PARTSTAT=NEEDS-ACTI
+ ON;X-OBM-ID=623:MAILTO:[email protected]
+END:VEVENT
+END:VCALENDAR


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to