зеркало из https://github.com/microsoft/docker.git
Merge pull request #27060 from yongtang/27021-inspect-show-env
Disable HTML escaping for JSON strings in `docker inspect`
This commit is contained in:
Коммит
420e22fad4
|
@ -81,7 +81,9 @@ func ParseForm(r *http.Request) error {
|
|||
func WriteJSON(w http.ResponseWriter, code int, v interface{}) error {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(code)
|
||||
return json.NewEncoder(w).Encode(v)
|
||||
enc := json.NewEncoder(w)
|
||||
enc.SetEscapeHTML(false)
|
||||
return enc.Encode(v)
|
||||
}
|
||||
|
||||
// VersionFromContext returns an API version from the context using APIVersionKey.
|
||||
|
|
|
@ -407,3 +407,13 @@ func (s *DockerSuite) TestInspectRootFS(c *check.C) {
|
|||
|
||||
c.Assert(len(imageJSON[0].RootFS.Layers), checker.GreaterOrEqualThan, 1)
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestInspectAmpersand(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
name := "test"
|
||||
out, _ := dockerCmd(c, "run", "--name", name, "--env", `TEST_ENV="soanni&rtr"`, "busybox", "env")
|
||||
c.Assert(out, checker.Contains, `soanni&rtr`)
|
||||
out, _ = dockerCmd(c, "inspect", name)
|
||||
c.Assert(out, checker.Contains, `soanni&rtr`)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче