Skip to content

Commit 529897e

Browse files
author
Bas van Kervel
committed
cmd/utils: strip excessive whitespace from api command line arguments
1 parent e50e3be commit 529897e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

cmd/utils/flags.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,16 @@ func MakeNAT(ctx *cli.Context) nat.Interface {
500500
return natif
501501
}
502502

503+
// MakeRPCModules splits input separated by a comma and trims excessive white
504+
// space from the substrings.
505+
func MakeRPCModules(input string) []string {
506+
result := strings.Split(input, ",")
507+
for i, r := range result {
508+
result[i] = strings.TrimSpace(r)
509+
}
510+
return result
511+
}
512+
503513
// MakeHTTPRpcHost creates the HTTP RPC listener interface string from the set
504514
// command line flags, returning empty if the HTTP endpoint is disabled.
505515
func MakeHTTPRpcHost(ctx *cli.Context) string {
@@ -652,11 +662,11 @@ func MakeSystemNode(name, version string, extra []byte, ctx *cli.Context) *node.
652662
HTTPHost: MakeHTTPRpcHost(ctx),
653663
HTTPPort: ctx.GlobalInt(RPCPortFlag.Name),
654664
HTTPCors: ctx.GlobalString(RPCCORSDomainFlag.Name),
655-
HTTPModules: strings.Split(ctx.GlobalString(RPCApiFlag.Name), ","),
665+
HTTPModules: MakeRPCModules(ctx.GlobalString(RPCApiFlag.Name)),
656666
WSHost: MakeWSRpcHost(ctx),
657667
WSPort: ctx.GlobalInt(WSPortFlag.Name),
658668
WSOrigins: ctx.GlobalString(WSAllowedOriginsFlag.Name),
659-
WSModules: strings.Split(ctx.GlobalString(WSApiFlag.Name), ","),
669+
WSModules: MakeRPCModules(ctx.GlobalString(WSApiFlag.Name)),
660670
}
661671
// Configure the Ethereum service
662672
accman := MakeAccountManager(ctx)

0 commit comments

Comments
 (0)