From 4d4dac367bd3d068f318f862a2560a0f02b4260a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 23 Aug 2023 09:47:13 +0200 Subject: [PATCH] Continued: - strip spaces off --- fba/helpers/software.py | 10 ++++++---- fba/http/federation.py | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fba/helpers/software.py b/fba/helpers/software.py index 8c77934..4d83b43 100644 --- a/fba/helpers/software.py +++ b/fba/helpers/software.py @@ -108,7 +108,7 @@ def alias(software: str) -> str: software = None else: logger.debug("software='%s' is being cleaned up further ...") - software = software.rstrip("!") + software = software.rstrip("!").strip() logger.debug("software[%s]='%s' - EXIT!", type(software), software) return software @@ -130,7 +130,8 @@ def strip_hosted_on(software: str) -> str: logger.debug("software[%s]='%s'", type(software), software) if " - " in software: - software = strip_until(software, " - ") + logger.debug("Stripping ' - ' of from software='%s' ...", software) + software = strip_until(software, " - ").strip() logger.debug("software='%s' - EXIT!", software) return software @@ -152,7 +153,8 @@ def strip_powered_by(software: str) -> str: logger.debug("software='%s'", software) if " - " in software: - software = strip_until(software, " - ") + logger.debug("Stripping ' - ' of from software='%s' ...", software) + software = strip_until(software, " - ").strip() logger.debug("software='%s' - EXIT!", software) return software @@ -172,7 +174,7 @@ def strip_until(software: str, until: str) -> str: return software # Next, strip until part - end = software.find(until) + end = software.strip().find(until) logger.debug("end[%s]=%d", type(end), end) if end > 0: diff --git a/fba/http/federation.py b/fba/http/federation.py index aa1adf9..e726ae5 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -438,6 +438,8 @@ def determine_software(domain: str, path: str = None) -> str: logger.debug("software='%s' has 'powered by' in it", software) software = version.remove(software_helper.strip_powered_by(software)) + software = software.strip() + logger.debug("software='%s' - EXIT!", software) return software -- 2.39.5