From c49f47ecabaa58e0da3066b340b01459cd483d63 Mon Sep 17 00:00:00 2001 From: Matt Joyce Date: Thu, 5 Dec 2024 20:39:40 +1100 Subject: [PATCH] check extension names don't have spoaces --- plugins/template/extension_registry.go | 11 ++++++++--- plugins/template/template.go | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/plugins/template/extension_registry.go b/plugins/template/extension_registry.go index af75808b..43690888 100644 --- a/plugins/template/extension_registry.go +++ b/plugins/template/extension_registry.go @@ -7,6 +7,7 @@ import ( "io" "os" "path/filepath" + "strings" "time" "gopkg.in/yaml.v3" @@ -118,9 +119,13 @@ func (r *ExtensionRegistry) Register(configPath string) error { return fmt.Errorf("failed to parse config file: %w", err) } - // Add validation - if err := r.validateExtensionDefinition(&ext); err != nil { - return fmt.Errorf("invalid extension configuration: %w", err) + // Validate extension name + if ext.Name == "" { + return fmt.Errorf("extension name cannot be empty") + } + + if strings.Contains(ext.Name, " ") { + return fmt.Errorf("extension name '%s' contains spaces - names must not contain spaces", ext.Name) } // Verify executable exists diff --git a/plugins/template/template.go b/plugins/template/template.go index 382053e0..d959f230 100644 --- a/plugins/template/template.go +++ b/plugins/template/template.go @@ -15,18 +15,18 @@ var ( fetchPlugin = &FetchPlugin{} sysPlugin = &SysPlugin{} extensionManager *ExtensionManager - Debug = true // Debug flag + Debug = false // Debug flag ) func init() { homedir, err := os.UserHomeDir() if err != nil { - // We should probably handle this error appropriately - return + debugf("Warning: could not initialize extension manager: %v\n", err) } configDir := filepath.Join(homedir, ".config/fabric") extensionManager = NewExtensionManager(configDir) + // Extensions will work if registry exists, otherwise they'll just fail gracefully } var pluginPattern = regexp.MustCompile(`\{\{plugin:([^:]+):([^:]+)(?::([^}]+))?\}\}`)