Explorar el Código

Sanitize username used for constructing log filenames.

On Windows, os/user.Current may return a username containing a backslash.
David Symonds hace 13 años
padre
commit
ab6a54c30d
Se han modificado 1 ficheros con 3 adiciones y 0 borrados
  1. 3 0
      glog_file.go

+ 3 - 0
glog_file.go

@@ -64,6 +64,9 @@ func init() {
 	if err == nil {
 	if err == nil {
 		userName = current.Username
 		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.
 // shortHostname returns its argument, truncating at the first period.