improve detection of expensive DTSTART RRULE values

This commit is contained in:
Ryan Petrello
2018-02-08 08:54:30 -05:00
parent e982f6ed06
commit 887f16023a

View File

@@ -150,12 +150,11 @@ class Schedule(CommonModel, LaunchTimeConfig):
# > UTC time. # > UTC time.
raise ValueError('RRULE UNTIL values must be specified in UTC') raise ValueError('RRULE UNTIL values must be specified in UTC')
if 'MINUTELY' in rrule or 'HOURLY' in rrule:
try: try:
first_event = x[0] first_event = x[0]
if first_event < now() - datetime.timedelta(days=365 * 5): if first_event < now() - datetime.timedelta(days=365 * 5):
# For older DTSTART values, if there are more than 1000 recurrences... raise ValueError('RRULE values with more than 1000 events are not allowed.')
if len(x[:1001]) > 1000:
raise ValueError('RRULE values that yield more than 1000 events are not allowed.')
except IndexError: except IndexError:
pass pass
return x return x