mirror of
https://github.com/FiloSottile/age.git
synced 2026-09-04 15:17:04 +00:00
plugin: always canonicalize plugin names
Reported by Joe Doyle of Trail of Bits.
This commit is contained in:
+6
-2
@@ -16,6 +16,7 @@ import (
|
||||
"os"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"filippo.io/age"
|
||||
"filippo.io/age/internal/format"
|
||||
@@ -44,11 +45,14 @@ type Plugin struct {
|
||||
broken bool
|
||||
}
|
||||
|
||||
// New creates a new Plugin with the given name.
|
||||
// New creates a new Plugin with the given case-insensitive name.
|
||||
//
|
||||
// For example, a plugin named "frood" would be invoked as "age-plugin-frood".
|
||||
func New(name string) (*Plugin, error) {
|
||||
return &Plugin{name: name, stdin: os.Stdin,
|
||||
if !validPluginName(name) {
|
||||
return nil, fmt.Errorf("invalid plugin name: %q", name)
|
||||
}
|
||||
return &Plugin{name: strings.ToLower(name), stdin: os.Stdin,
|
||||
stdout: os.Stdout, stderr: os.Stderr}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user