mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
Fix URL validation to only accept HTTP/HTTPS schemes for Ollama embeddings
- Update _validate_url() to restrict schemes to 'http' and 'https' only - Fixes CI test failures for ftp://invalid-scheme test cases - Maintains security by preventing non-web protocols Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -93,7 +93,7 @@ class EmbeddingConfigurator:
|
||||
|
||||
@staticmethod
|
||||
def _validate_url(url):
|
||||
"""Validate that a URL is properly formatted."""
|
||||
"""Validate that a URL is properly formatted and uses HTTP/HTTPS scheme."""
|
||||
if not url:
|
||||
return False
|
||||
|
||||
@@ -101,7 +101,10 @@ class EmbeddingConfigurator:
|
||||
|
||||
try:
|
||||
result = urlparse(url)
|
||||
return all([result.scheme, result.netloc])
|
||||
return all([
|
||||
result.scheme in ('http', 'https'),
|
||||
result.netloc
|
||||
])
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user