From c8ed6063afc654e5e24dbfce4f13d7b2824afbe6 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Tue, 10 Mar 2026 09:41:28 +0100 Subject: [PATCH] Fix comparison of quoted URLs The current code compares quoted URLs, i.e. `quoted_url.endswith(quote(document_type))`. However, URL encoding is case-insensitive, so this fails if the SMP escapes characters in their URL with e.g. %3a, but Python `quote` quotes with %3A. This PR flips the check by comparing `unquote(quoted_url).endswith(document_type)` which should remove any inconsistencies on quoting. --- src/peppol_py/smp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/peppol_py/smp.py b/src/peppol_py/smp.py index 347f186..16ffbd8 100644 --- a/src/peppol_py/smp.py +++ b/src/peppol_py/smp.py @@ -86,7 +86,7 @@ def get_service_info_for_participant_from_smp(participant_id, document_type, tes '::' + Scope.InstanceIdentifier from the Peppol header.""" service_urls = get_service_urls_for_participant_from_smp(participant_id, test_environment, timeout) - service_url = next((url for url in service_urls if url.endswith(urllib.parse.quote(document_type))), None) + service_url = next((url for url in service_urls if urllib.parse.unquote(url).endswith(document_type)), None) if not service_url: raise make_sendpeppol_error("{0} not found in {1}".format(document_type, [urllib.parse.unquote(url) for url in service_urls]), 'not-found-in-smp')