ソースを参照

Sanitize username used for constructing log filenames.

On Windows, os/user.Current may return a username containing a backslash.
David Symonds 12 年 前
コミット
ab6a54c30d
1 ファイル変更3 行追加0 行削除
  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.