Skip to content

Commit

Permalink
Catch errors when we have invalid rrules that lib-recur can't parse.
Browse files Browse the repository at this point in the history
  • Loading branch information
toolstack authored and Gitsaibot committed Dec 3, 2023
1 parent 74b31d4 commit 57f90a3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/src/main/java/com/android/calendar/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,19 @@ static int checkRRuleEventDate( String rrule, long startTime, int endDay) {

// Use the Year/Month/Day startTime values to create a firstInstance.
DateTime firstInstance = new DateTime(startYear, startMonth, startDay);
RecurrenceSet newRecurrenceSet;

// Wrap the recurrent set creation in a try/catch to ensure we don't run into an invalid
// rule set that lib-recur can't parse.
try {
newRecurrenceSet = new RecurrenceSet(firstInstance, new RuleInstances(rule));
} catch (Exception e) {
return endDay;
}

// Create the recurrence set for the rule, we're only going to look at the first one
// as it should match the firstInstance if this is a valid event from Android.
for (DateTime instance:new RecurrenceSet(firstInstance, new RuleInstances(rule))) {
for (DateTime instance:newRecurrenceSet) {
if (!instance.equals(firstInstance)) {
// If this isn't a valid event, return 0 so it gets removed from the event list.
return 0;
Expand Down

0 comments on commit 57f90a3

Please sign in to comment.