mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-08-05 02:45:28 +00:00
fix(email): parse IMAP folder names without regex
This commit is contained in:
parent
986c3db1a7
commit
7a900c976a
1 changed files with 14 additions and 3 deletions
|
|
@ -379,10 +379,21 @@ def _record_email_received_events(owner: str, account_id: str | None, folder: st
|
|||
|
||||
def _folder_name_from_list_line(line) -> str | None:
|
||||
decoded = line.decode() if isinstance(line, bytes) else str(line)
|
||||
match = re.search(r'"([^"]*)"\s*$|(\S+)\s*$', decoded)
|
||||
if not match:
|
||||
decoded = decoded.rstrip()
|
||||
if not decoded:
|
||||
return None
|
||||
return match.group(1) or match.group(2)
|
||||
if decoded.endswith('"'):
|
||||
escaped = False
|
||||
for idx in range(len(decoded) - 2, -1, -1):
|
||||
ch = decoded[idx]
|
||||
if ch == '"' and not escaped:
|
||||
value = decoded[idx + 1 : -1]
|
||||
return value.replace(r"\\", "\\").replace(r"\"", '"')
|
||||
escaped = ch == "\\" and not escaped
|
||||
if ch != "\\":
|
||||
escaped = False
|
||||
parts = decoded.split()
|
||||
return parts[-1] if parts else None
|
||||
|
||||
|
||||
def _imap_status_ok(status) -> bool:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue