Skip to content

Commit

Permalink
Escape container names.
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarmol committed Jun 26, 2015
1 parent ee119e2 commit 39b29da
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pages/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pages/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions pages/pages.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"fmt"
"html/template"
"net/http"
"net/url"
"strings"

auth "github.com/abbot/go-http-auth"
Expand Down Expand Up @@ -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, "/")
}

0 comments on commit 39b29da

Please sign in to comment.