Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bc8eabc

Browse files
committedSep 4, 2016
Allow windows environment variables to contain =
Fix issue where environment variables with embedded equals signs were being dropped and not passed to the container. Fixes moby#26178. Signed-off-by: Matt Richardson <[email protected]>
1 parent 1a04d7b commit bc8eabc

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
 

‎libcontainerd/utils_windows.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
func setupEnvironmentVariables(a []string) map[string]string {
1111
r := make(map[string]string)
1212
for _, s := range a {
13-
arr := strings.Split(s, "=")
13+
arr := strings.SplitN(s, "=", 2)
1414
if len(arr) == 2 {
1515
r[arr[0]] = arr[1]
1616
}

‎libcontainerd/utils_windows_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package libcontainerd
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestEnvironmentParsing(t *testing.T) {
8+
env := []string{"foo=bar", "car=hat", "a=b=c"}
9+
result := setupEnvironmentVariables(env)
10+
if len(result) != 3 || result["foo"] != "bar" || result["car"] != "hat" || result["a"] != "b=c" {
11+
t.Fatalf("Expected map[foo:bar car:hat a:b=c], got %v", result)
12+
}
13+
}

0 commit comments

Comments
 (0)
Please sign in to comment.