Skip to content

Commit

Permalink
fix(pkg): Fixed an issue where wails new would throw an error if the …
Browse files Browse the repository at this point in the history
…author name contained non-JSON legal characters.
  • Loading branch information
taisei-86 committed Jul 26, 2024
1 parent 7a40cc5 commit ce38bea
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions v2/pkg/git/git.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package git

import (
"encoding/json"
"fmt"
"html/template"
"runtime"
"strings"
Expand Down Expand Up @@ -31,7 +33,17 @@ func Email() (string, error) {
// Name tries to retrieve the
func Name() (string, error) {
stdout, _, err := shell.RunCommand(".", gitcommand(), "config", "user.name")
if err != nil {
return "", err
}

name := template.JSEscapeString(strings.TrimSpace(stdout))

// Check if username is JSON compliant
var js json.RawMessage
jsonVal := fmt.Sprintf(`{"name": "%s"}`, name)
err = json.Unmarshal([]byte(jsonVal), &js)

return name, err
}

Expand Down

0 comments on commit ce38bea

Please sign in to comment.