From fbac0ffadafbe4f967e6eae29476ac72fb8bf52c Mon Sep 17 00:00:00 2001 From: giuliof Date: Mon, 21 Sep 2020 19:36:31 +0200 Subject: [PATCH] [B.END] Patch: TEXT escaping. This time will work properly? --- getInfo.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/getInfo.py b/getInfo.py index c2e05e5..0888106 100755 --- a/getInfo.py +++ b/getInfo.py @@ -7,6 +7,13 @@ import re import glob import pytz +# Parameter: a TEXT string +# Returns: the escaped string, according to RFC 5545 §3.3.11 +def escape(string): + string = re.sub(r"\\n", "\n", string) + string = re.sub(r"\\(.)", r"\1", string) + return string + # Parameter: list of options in format key=value # Returns: dictionary of given options in format # {key : value, ...} @@ -72,8 +79,7 @@ def getEvents(baseDay, interval): # Check if this line is part of a long content lines (RFC §3.1) # i.e. begins with SPACE or HTAB. if item[0] == ' ' or item[0] == '\t': - # Escape text as in §3.3.11 - item = re.sub(r"\\(.)",r"\1", item) + item = escape(item) try: event_dict[propertyName] += item.lstrip() except KeyError: @@ -125,9 +131,9 @@ def getEvents(baseDay, interval): event_dict['DATETIME'] = event_parsed_dt.astimezone(local_tz) event_dict['ALLDAY'] = False elif k[0] == 'LOCATION': - event_dict['LOCATION'] = re.sub(r"\\(.)",r"\1", k[1]) + event_dict['LOCATION'] = escape(k[1]) elif k[0] == 'DESCRIPTION': - event_dict['DESCRIPTION'] = re.sub(r"\\(.)",r"\1", k[1]) + event_dict['DESCRIPTION'] = escape(k[1]) elif k[0] == 'RRULE': options = parseOptions(k[1:]) repetition['single'] = False