1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-09-12 20:30:57 +00:00

Workaround for broken contact PHOTO from InfCloud

See issue #1205
This commit is contained in:
Unrud 2022-01-15 23:39:05 +01:00
parent 2a29ad6a17
commit a4150c633a
5 changed files with 28 additions and 5 deletions

View file

@ -27,6 +27,7 @@ import binascii
import contextlib
import math
import os
import re
import sys
from datetime import datetime, timedelta
from hashlib import sha256
@ -42,6 +43,16 @@ from radicale.item import filter as radicale_filter
from radicale.log import logger
def read_components(s: str) -> List[vobject.base.Component]:
"""Wrapper for vobject.readComponents"""
# Workaround for bug in InfCloud
# PHOTO is a data URI
s = re.sub(r"^(PHOTO(?:;[^:\r\n]*)?;ENCODING=b(?:;[^:\r\n]*)?:)"
r"data:[^;,\r\n]*;base64,", r"\1", s,
flags=re.MULTILINE | re.IGNORECASE)
return list(vobject.readComponents(s))
def predict_tag_of_parent_collection(
vobject_items: Sequence[vobject.base.Component]) -> Optional[str]:
"""Returns the predicted tag or `None`"""