From: Roland Häder Date: Mon, 10 Jul 2023 22:58:18 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3352012c926e58415ede27defe0913445a027331;p=fba.git Continued: - code UTF-8 international domains to punycode (IDNA) here, too --- diff --git a/daemon.py b/daemon.py index c53fcb6..bef82a1 100755 --- a/daemon.py +++ b/daemon.py @@ -215,8 +215,11 @@ LIMIT ?", [ @router.get(config.get("base_url") + "/api/domain.json", response_class=JSONResponse) def api_domain(domain: str): + if domain is None: + raise HTTPException(status_code=400, detail="Invalid request, parameter 'domain' missing") + # Tidy up domain name - domain = tidyup.domain(domain) + domain = tidyup.domain(domain).encode("idna").decode("utf-8") if not utils.is_domain_wanted(domain): raise HTTPException(status_code=500, detail=f"domain='{domain}' is not wanted") @@ -373,8 +376,11 @@ def top(request: Request, mode: str, value: str, amount: int = config.get("api_l @router.get(config.get("base_url") + "/infos") def rss(request: Request, domain: str): + if domain is None: + raise HTTPException(status_code=400, detail="Invalid request, parameter 'domain' missing") + # Tidy up domain name - domain = tidyup.domain(domain) + domain = tidyup.domain(domain).encode("idna").decode("utf-8") if not utils.is_domain_wanted(domain): raise HTTPException(status_code=500, detail=f"domain='{domain}' is not wanted") @@ -408,7 +414,7 @@ def rss(request: Request, domain: str): @router.get(config.get("base_url") + "/rss") def rss(request: Request, domain: str = None): if domain is not None: - domain = tidyup.domain(domain) + domain = tidyup.domain(domain).encode("idna").decode("utf-8") wildchar = "*." + ".".join(domain.split(".")[-domain.count("."):]) punycode = domain.encode("idna").decode("utf-8")