Skip to content

Commit

Permalink
work-around for inconsistent invoice.path encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
cod3monk committed Feb 18, 2024
1 parent 1abb222 commit 8627d7d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion easyverein/modules/invoice.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import logging
from pathlib import Path
import re
from typing import List
import urllib

from requests.structures import CaseInsensitiveDict

Expand Down Expand Up @@ -169,4 +171,10 @@ def get_attachment(
"Unable to obtain a valid path for given invoice."
)

return self.c.fetch_file(path)
# Fix for unencoded characters - should probably be fixed in easyverein API
m = re.fullmatch(r'^(.*\&path=)(.*)(&storedInS3=True)$', path.unicode_string())
url_components = list(m.groups())
if '%' not in url_components[1]:
url_components[1] = urllib.parse.quote(url_components[1])

return self.c.fetch_file(''.join(url_components))

0 comments on commit 8627d7d

Please sign in to comment.