From: Roland Häder Date: Wed, 19 Jul 2023 15:09:54 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ef14cc7c623e84b19e0ef4764ffecd419b639a60;p=fba.git Continued: - added some checks for parameter 'origin' --- diff --git a/fba/http/federation.py b/fba/http/federation.py index 062a486..6ad8413 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -163,7 +163,11 @@ def fetch_peers(domain: str, software: str, origin: str) -> list: domain_helper.raise_on(domain) if not isinstance(software, str) and software is not None: - raise ValueError(f"software[]='{type(software)}' is not of type 'str'") + raise ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'") + elif not isinstance(origin, str) and origin is not None: + raise ValueError(f"Parameter origin[]='{type(origin)}' is not of type 'str'") + elif isinstance(origin, str) and origin == "": + raise ValueError("Parameter 'origin' is empty") if software == "misskey": logger.debug("Invoking misskey.fetch_peers(%s) ...", domain) @@ -440,7 +444,8 @@ def fetch_generator_from_path(domain: str, path: str = "/") -> str: logger.debug("Fetching path='%s' from domain='%s' ...", path, domain) response = network.fetch_response( - domain, path, + domain, + path, network.web_headers, (config.get("connection_timeout"), config.get("read_timeout")), allow_redirects=True @@ -454,7 +459,7 @@ def fetch_generator_from_path(domain: str, path: str = "/") -> str: logger.debug("doc[]='%s'", type(doc)) generator = doc.find("meta", {"name" : "generator"}) site_name = doc.find("meta", {"property": "og:site_name"}) - platform = doc.find("meta", {"property": "og:platform"}) + platform = doc.find("meta", {"property": "og:platform"}) logger.debug("generator[]='%s',site_name[]='%s',platform[]='%s'", type(generator), type(site_name), type(platform)) if isinstance(generator, bs4.element.Tag) and isinstance(generator.get("content"), str):