From 1a94a7badcc3c21e424d60d60f044c9241c87b58 Mon Sep 17 00:00:00 2001 From: Dariusz L Date: Thu, 2 Jul 2026 23:43:37 +0200 Subject: [PATCH] Validate civitai URL input before parsing Add an early guard in core/sources/civitai.py to return None for non-string or empty URL inputs before calling urlparse. This prevents exceptions and unexpected behavior when callers pass None or empty values, making the parser more robust. --- core/sources/civitai.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/sources/civitai.py b/core/sources/civitai.py index 8e2fed7..0db9237 100644 --- a/core/sources/civitai.py +++ b/core/sources/civitai.py @@ -640,6 +640,8 @@ def parse_civitai_url(url: str) -> Optional[Dict[str, Any]]: """ Parse a CivitAI URL to extract model/version info. """ + if not isinstance(url, str) or not url.strip(): + return None parsed = urlparse(url) if "civitai.com" not in parsed.netloc: return None