From 8e6e74060f7c715ba28e4947144de0d0b7a0a2d6 Mon Sep 17 00:00:00 2001 From: James Bowes Date: Sun, 11 Aug 2013 18:39:25 -0300 Subject: [PATCH] Escape spaces and hyphens when generating cli filenames --- main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 11c896e..fbf91b4 100644 --- a/main.go +++ b/main.go @@ -16,6 +16,7 @@ import ( var ( wsReplacer = strings.NewReplacer("__", "_", "_", " ") + revWsReplacer = strings.NewReplacer(" ", "_", "_", "__", "-", "--") // set last modifed to server startup. close enough to release. lastModified = time.Now() @@ -137,8 +138,8 @@ func cliMode(vendor string, status string, color string, args []string) { } d := Data{vendor, status, c} - // XXX could escape here - name := vendor + "-" + status + "-" + color + ".png" + name := fmt.Sprintf("%s-%s-%s.png", revWsReplacer.Replace(vendor), + revWsReplacer.Replace(status), color); if len(args) > 1 { fatal("You can only specify one output file name")