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.
This commit is contained in:
Dariusz L
2026-07-02 23:43:37 +02:00
parent 56ec5c3083
commit 1a94a7badc
+2
View File
@@ -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