]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Mon, 10 Jul 2023 22:58:18 +0000 (00:58 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 10 Jul 2023 22:58:18 +0000 (00:58 +0200)
- code UTF-8 international domains to punycode (IDNA) here, too

daemon.py

index c53fcb6ec6c860c5ea1c323ee0a426c43d090f3b..bef82a13871446ff5fc43ea5d6acb8d76334142b 100755 (executable)
--- 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")