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 7546393c4c [FIX] ICALAttributeDTO should sanitize invalid dtstamp
(#3084)
7546393c4c is described below
commit 7546393c4c44d9e4613e3bb9a19431a3352b8b68
Author: Benoit TELLIER <[email protected]>
AuthorDate: Wed Jul 8 07:22:10 2026 +0200
[FIX] ICALAttributeDTO should sanitize invalid dtstamp (#3084)
---
.../james/transport/mailets/model/ICALAttributeDTO.java | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 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 ce648c3dc5..2947f772fe 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
@@ -24,6 +24,8 @@ import java.util.Objects;
import java.util.Optional;
import org.apache.james.core.MailAddress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Preconditions;
@@ -36,6 +38,8 @@ import net.fortuna.ical4j.model.property.Uid;
public class ICALAttributeDTO {
+ private static final Logger LOGGER =
LoggerFactory.getLogger(ICALAttributeDTO.class);
+
public static final String DEFAULT_SEQUENCE_VALUE = "0";
public static class Builder {
@@ -47,7 +51,7 @@ public class ICALAttributeDTO {
Optional<String> method = optionalOf(calendar.getMethod());
Optional<String> recurrenceId =
optionalOf(vevent.getRecurrenceId());
Optional<String> sequence = optionalOf(vevent.getSequence());
- Optional<DtStamp> dtstamp = vevent.getDateStamp();
+ Optional<String> dtstamp =
vevent.getDateStamp().flatMap(this::safeValue);
Preconditions.checkNotNull(ical);
@@ -57,7 +61,7 @@ public class ICALAttributeDTO {
uid.map(Uid::getValue), sender.asString(),
recipient.asString(),
replyTo.asString(),
- dtstamp.map(DtStamp::getValue), method, sequence,
+ dtstamp, method, sequence,
recurrenceId);
}
@@ -65,6 +69,15 @@ public class ICALAttributeDTO {
return Optional.ofNullable(property).map(Property::getValue);
}
+ private Optional<String> safeValue(DtStamp dtStamp) {
+ try {
+ return Optional.ofNullable(dtStamp.getValue());
+ } catch (Exception e) {
+ LOGGER.warn("Ignoring non RFC-5545 compliant DTSTAMP value",
e);
+ return Optional.empty();
+ }
+ }
+
@FunctionalInterface
public interface RequiresSender {
RequiresRecipient sender(MailAddress sender);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]