Skip to content

Agent Zero AI framework

Merge branch 'pr/1229' into development

frdelea8ee6d3f77b
diff --cc plugins/plugin_installer/helpers/install.py
index db8542060,8d90e6ee7..0c2233342
--- a/plugins/plugin_installer/helpers/install.py
+++ b/plugins/plugin_installer/helpers/install.py
@@@ -24,18 -26,28 +26,18 @@@ def _get_user_plugins_dir() -> str
return files.get_abs_path(files.USER_DIR, files.PLUGINS_DIR)
- def _sanitize_plugin_name(name: str) -> str:
-def _derive_git_plugin_name(url: str) -> str:
- """Derive the canonical plugin ID from a Git repository URL."""
- repo_name = url.rstrip("/").split("/")[-1]
- if repo_name.endswith(".git"):
- repo_name = repo_name[:-4]
- if not repo_name:
- raise ValueError("Could not derive plugin name from URL")
- return repo_name
-
-
-def _derive_zip_plugin_name(
- plugin_root: str, extract_dir: str, original_filename: str | None
-) -> str:
- """Resolve the plugin ID for an uploaded ZIP archive."""
- if plugin_root != extract_dir:
- return os.path.basename(plugin_root)
-
- upload_name = Path((original_filename or "").strip()).name
- plugin_name = Path(upload_name).stem
- if not plugin_name:
- raise ValueError("Could not derive plugin name from uploaded filename")
- return plugin_name
++ def _sanitize_plugin_name(name: str) -> str:
+ """Validate and sanitize a plugin directory name.
+ Converts dots and dashes to underscores for Python import compatibility.
+ Raises ValueError if the name is unsafe for filesystem use."""
+ name = name.strip().strip(".")
- name = re.sub(r"[^a-zA-Z0-9]+", "_", name)
++ name = re.sub(r"[-.]", "_", name)
+ if not name or not _SAFE_NAME_RE.match(name):
+ raise ValueError(
+ f"Invalid plugin name: '{name}'. "
+ "Names must start with a letter or digit and contain only letters, digits, or underscores."
+ )
+ return name
def validate_plugin_dir(path: str) -> PluginMetadata: