Merge pull request #786 from vmarmol/fix

Escape container names.
This commit is contained in:
Rohit Jnagal 2015-06-26 09:52:29 -07:00
commit 571b2baedb
3 changed files with 12 additions and 2 deletions

View File

@ -229,7 +229,7 @@ func serveContainersPage(m manager.Manager, w http.ResponseWriter, u *url.URL) e
data := &pageData{
DisplayName: displayName,
ContainerName: cont.Name,
ContainerName: escapeContainerName(cont.Name),
ParentContainers: parentContainers,
Subcontainers: subcontainerLinks,
Spec: cont.Spec,

View File

@ -130,7 +130,7 @@ func serveDockerPage(m manager.Manager, w http.ResponseWriter, u *url.URL) error
}
data = &pageData{
DisplayName: displayName,
ContainerName: cont.Name,
ContainerName: escapeContainerName(cont.Name),
ParentContainers: parentContainers,
Spec: cont.Spec,
Stats: cont.Stats,

View File

@ -18,6 +18,7 @@ import (
"fmt"
"html/template"
"net/http"
"net/url"
"strings"
auth "github.com/abbot/go-http-auth"
@ -159,3 +160,12 @@ func getContainerDisplayName(cont info.ContainerReference) string {
return displayName
}
// Escape the non-path characters on a container name.
func escapeContainerName(containerName string) string {
parts := strings.Split(containerName, "/")
for i := range parts {
parts[i] = url.QueryEscape(parts[i])
}
return strings.Join(parts, "/")
}