Code Repositories xandikos / bdeb9f5
Check for multiple control characters. Jelmer Vernooń≥ 11 months ago
1 changed file(s) with 8 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
2626 from icalendar.prop import vText
2727 from xandikos.store import File, InvalidFileContents
2828
29 # TODO(jelmer): Populate this further based on
30 # https://tools.ietf.org/html/rfc5545#3.3.11
31 _INVALID_CONTROL_CHARACTERS = ['\x0c', '\x01']
32
2933
3034 def validate_calendar(cal):
3135 """Validate a calendar object.
4448 # Check text fields for invalid characters
4549 for (name, value) in comp.items():
4650 if isinstance(value, vText):
47 if '\x0c' in value:
48 yield "Invalid character in field %s" % name
51 for c in _INVALID_CONTROL_CHARACTERS:
52 if c in value:
53 yield "Invalid character %s in field %s" % (
54 c.encode('unicode_escape'), name)
4955 for required in comp.required:
5056 try:
5157 comp[required]