From 8627d7dcb2e3a14e034a966cc912c17743ee7df5 Mon Sep 17 00:00:00 2001 From: codemonk Date: Sun, 18 Feb 2024 17:29:46 +0100 Subject: [PATCH] work-around for inconsistent invoice.path encoding --- easyverein/modules/invoice.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/easyverein/modules/invoice.py b/easyverein/modules/invoice.py index 4b11316..853475a 100644 --- a/easyverein/modules/invoice.py +++ b/easyverein/modules/invoice.py @@ -1,6 +1,8 @@ import logging from pathlib import Path +import re from typing import List +import urllib from requests.structures import CaseInsensitiveDict @@ -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))