~gitpocket/gitpocket

1

fix(cli): read whole password lines from stdin

commit
ef9167bb0e271e16e00190335578bd4a6a870e89 browse tree
parent
d4538466f4c2e13696df5d5a2886e837a50ce4d8
author
obscurejames <354576047+obscurejames@users.noreply.github.com>
signature
Verified ~james signed with a key registered by ~james
date
2026-11-07 16:00 UTC

1 files changed, +8 −4

main.go modified

@@ -1,6 +1,7 @@
11 package main
22
33 import (
4+ "bufio"
45 "flag"
56 "fmt"
67 "log"
@@ -100,8 +101,7 @@ func main() {
100101 os.Exit(2)
101102 }
102103 store := mustStore(*root)
103- var password string
104- fmt.Fscanln(os.Stdin, &password)
104+ password := readLine()
105105 if _, err := store.CreateUser(args[1], password); err != nil {
106106 log.Fatal(err)
107107 }
@@ -114,8 +114,7 @@ func main() {
114114 if err != nil {
115115 log.Fatal("no such user")
116116 }
117- var password string
118- fmt.Fscanln(os.Stdin, &password)
117+ password := readLine()
119118 if err := store.SetPassword(u.ID, password); err != nil {
120119 log.Fatal(err)
121120 }
@@ -242,3 +241,8 @@ func serve(root string, args []string) {
242241 log.Printf("gitpocket listening on %s for %s", *listen, *host)
243242 log.Fatal(srv.ListenAndServe())
244243 }
244+
245+func readLine() string {
246+ line, _ := bufio.NewReader(os.Stdin).ReadString('\n')
247+ return strings.TrimRight(line, "\r\n")
248+}