Browse Source

Sanitize username used for constructing log filenames.

On Windows, os/user.Current may return a username containing a backslash.
David Symonds 12 years ago
parent
commit
ab6a54c30d
1 changed files with 3 additions and 0 deletions
  1. 3 0
      glog_file.go

+ 3 - 0
glog_file.go

@@ -64,6 +64,9 @@ func init() {
 	if err == nil {
 		userName = current.Username
 	}
+
+	// Sanitize userName since it may contain filepath separators on Windows.
+	userName = strings.Replace(userName, `\`, "_", -1)
 }
 
 // shortHostname returns its argument, truncating at the first period.