M cmd/moac-pwgen/main.go => cmd/moac-pwgen/main.go +9 -0
@@ 12,6 12,7 @@ import (
"git.sr.ht/~seirdy/moac/v2/internal/sanitize"
"git.sr.ht/~seirdy/moac/v2/pwgen"
"git.sr.ht/~sircmpwn/getopt"
+ "github.com/rivo/uniseg"
)
const (
@@ 152,6 153,14 @@ func main1() int {
return 1
}
+ graphemes := uniseg.NewGraphemes(strings.Join(args, ""))
+ for graphemes.Next() {
+ if len(graphemes.Runes()) > 1 {
+ fmt.Fprintf(os.Stderr, "warning: charsets contain grapheme clusters, will be treated as distinct codepoints\n")
+ break
+ }
+ }
+
pwr.CharsetsWanted = charsets.ParseCharsets(setCharsetNames(args))
pw, err := pwgen.GenPW(pwr)
M cmd/moac/main.go => cmd/moac/main.go +9 -0
@@ 12,6 12,7 @@ import (
"git.sr.ht/~seirdy/moac/v2/internal/cli"
"git.sr.ht/~sircmpwn/getopt"
"golang.org/x/term"
+ "github.com/rivo/uniseg"
)
const (
@@ 159,6 160,14 @@ func getOutput() (output float64, exitEarly bool, err error) {
return output, exitEarly, fmt.Errorf("moac: %w", err)
}
+ graphemes := uniseg.NewGraphemes(givens.Password)
+ for graphemes.Next() {
+ if len(graphemes.Runes()) > 1 {
+ fmt.Fprintf(os.Stderr, "warning: charsets contain grapheme clusters, will be treated as distinct codepoints\n")
+ break
+ }
+ }
+
cmd := strengthCmd
if len(os.Args) > optind {