diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 308ddb778..0e486a6f0 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -16,8 +16,8 @@ }, { "ImportPath": "github.com/coreos/go-etcd/etcd", - "Comment": "v0.2.0-rc1-127-g6fe04d5", - "Rev": "6fe04d580dfb71c9e34cbce2f4df9eefd1e1241e" + "Comment": "v0.2.0-rc1-130-g6aa2da5", + "Rev": "6aa2da5a7a905609c93036b9307185a04a5a84a5" }, { "ImportPath": "github.com/jonboulle/clockwork", diff --git a/Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/requests.go b/Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/requests.go index fa6d36a9f..2741cd098 100644 --- a/Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/requests.go +++ b/Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/requests.go @@ -379,11 +379,13 @@ func buildValues(value string, ttl uint64) url.Values { return v } -// convert key string to http path exclude version +// convert key string to http path exclude version, including URL escaping // for example: key[foo] -> path[keys/foo] +// key[/%z] -> path[keys/%25z] // key[/] -> path[keys/] func keyToPath(key string) string { - p := path.Join("keys", key) + // URL-escape our key, except for slashes + p := strings.Replace(url.QueryEscape(path.Join("keys", key)), "%2F", "/", -1) // corner case: if key is "/" or "//" ect // path join will clear the tailing "/" diff --git a/Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/requests_test.go b/Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/requests_test.go new file mode 100644 index 000000000..7a2bd190a --- /dev/null +++ b/Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/requests_test.go @@ -0,0 +1,22 @@ +package etcd + +import "testing" + +func TestKeyToPath(t *testing.T) { + tests := []struct { + key string + wpath string + }{ + {"", "keys/"}, + {"foo", "keys/foo"}, + {"foo/bar", "keys/foo/bar"}, + {"%z", "keys/%25z"}, + {"/", "keys/"}, + } + for i, tt := range tests { + path := keyToPath(tt.key) + if path != tt.wpath { + t.Errorf("#%d: path = %s, want %s", i, path, tt.wpath) + } + } +}