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:
yuchou87
2026-02-21 13:45:00 +08:00
parent 59e9c55454
commit 33058b534e
+4
View File
@@ -73,6 +73,10 @@ func loadEnvFile(path string) (map[string]string, error) {
key := strings.TrimSpace(parts[0])
value := strings.TrimSpace(parts[1])
if key == "" {
return nil, fmt.Errorf("invalid format at line %d: empty key", lineNum)
}
// Remove surrounding quotes if present
if len(value) >= 2 {
if (value[0] == '"' && value[len(value)-1] == '"') ||