Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ switch, and thus all their contributions are dual-licensed.
- Dominik Kozaczko <dominik@MASKED>
- Elliot Hughes <elliot.hughes@gmail.com> (gh: @ElliotJH) **D**
- Elvis Pranskevichus <el@MASKED>
- Enes Uygur (gh: @Enesuygurs) **D**
- Fan Huang <fanhuang.scb@gmail.com>(gh: @fhuang5) **D**
- Florian Rathgeber (gh: @kynan) **D**
- Gabriel Bianconi <gabriel@MASKED> (gh: @GabrielBianconi) **D**
Expand Down
6 changes: 6 additions & 0 deletions changelog.d/1634.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
rrulestr now raises a clearer ``ValueError`` when a line cannot be split into
a valid property name, which usually happens when a datetime is written with
colons (e.g. ``UNTIL=2019-03-29T00:59:59``). The error now shows the whole
line and explains that RFC 5545 datetimes take no delimiters, instead of
reporting a confusing "unsupported property: FREQ=YEARLY". Reported by
@tamis-laan (gh issue #960). Fixed by @Enesuygurs (gh pr #1634).
12 changes: 11 additions & 1 deletion src/dateutil/rrule.py
Original file line number Diff line number Diff line change
Expand Up @@ -1723,8 +1723,18 @@ def _parse_rfc(self, s,
raise ValueError("Multiple DTSTART values specified:" +
value)
dtstart = dtvals[0]
else:
elif re.match(r"[A-Z0-9-]+$", name):
raise ValueError("unsupported property: "+name)
else:
# Not a valid property name, most likely because the line
# was split on a colon inside a value (gh issue #960).
raise ValueError(
"RRULE contains invalid property or stray colon:\n" +
line + "\n\n" +
"This commonly occurs when specifying a datetime "
"using delimiters, e.g. 2025-06-07T12:34:56; "
"RFC 5545 requires datetimes specified with no "
"delimiters, e.g. 20250607T123456")
if (forceset or len(rrulevals) > 1 or rdatevals
or exrulevals or exdatevals):
if not parser and (rdatevals or exdatevals):
Expand Down
11 changes: 11 additions & 0 deletions tests/test_rrule.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import copy
import itertools
import pickle
import re
import unittest
from datetime import date, datetime, timedelta
from functools import partial
Expand Down Expand Up @@ -3071,6 +3072,16 @@ def testStrInvalidByDay(self):
"BYDAY=-1OK;" # This part is invalid
"WKST=SU"))

def testStrUnsupportedProperty(self):
with pytest.raises(ValueError, match=re.escape("X-ABC-MMSUBJ")):
rrulestr("X-ABC-MMSUBJ:19970902T090000")

def testStrDatetimeWithColons(self):
# gh issue #960
rule = "FREQ=YEARLY;WKST=MO;UNTIL=2019-03-29T00:59:59+01:00"
with pytest.raises(ValueError, match=re.escape(rule)):
rrulestr(rule)

def testBadBySetPos(self):
self.assertRaises(ValueError,
rrule, MONTHLY,
Expand Down
Loading