fix(mcp): reject empty keys in loadEnvFile
A line like '=value' would result in envVars[""] = "value", producing an invalid environment entry for the child process. Return an error instead when the key is empty.
This commit is contained in:
parent
59e9c55454
commit
33058b534e
1 changed files with 4 additions and 0 deletions
|
|
@ -73,6 +73,10 @@ func loadEnvFile(path string) (map[string]string, error) {
|
||||||
key := strings.TrimSpace(parts[0])
|
key := strings.TrimSpace(parts[0])
|
||||||
value := strings.TrimSpace(parts[1])
|
value := strings.TrimSpace(parts[1])
|
||||||
|
|
||||||
|
if key == "" {
|
||||||
|
return nil, fmt.Errorf("invalid format at line %d: empty key", lineNum)
|
||||||
|
}
|
||||||
|
|
||||||
// Remove surrounding quotes if present
|
// Remove surrounding quotes if present
|
||||||
if len(value) >= 2 {
|
if len(value) >= 2 {
|
||||||
if (value[0] == '"' && value[len(value)-1] == '"') ||
|
if (value[0] == '"' && value[len(value)-1] == '"') ||
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue