Skip to content

Commit

Permalink
[BUGFIX] Fix password not saving to clipboard when AutoClip and SafeC…
Browse files Browse the repository at this point in the history
…ontent are both enabled

Fixed an issue where enabling both AutoClip and SafeContent prevented passwords from being saved to the clipboard.
Added tests to cover this case.

Signed-off-by: Alex Wallner <[email protected]>
  • Loading branch information
letfadude committed Feb 18, 2025
1 parent 01b6ff1 commit c4dc849
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/action/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (s *Action) showGetContent(ctx context.Context, sec gopass.Secret) (string,
// everything but the first line.
if config.Bool(ctx, "show.safecontent") && !ctxutil.IsForce(ctx) && ctxutil.IsShowParsing(ctx) {
body := showSafeContent(sec)
if IsAlsoClip(ctx) {
if IsAlsoClip(ctx) || config.Bool(ctx, "show.autoclip"){
return pw, body, nil
}

Expand Down
12 changes: 12 additions & 0 deletions internal/action/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,18 @@ func TestShowAutoClip(t *testing.T) {
stdoutBuf.Reset()
stderrBuf.Reset()
})

// gopass show foo with show.autoclip and show.safecontent true
// -> ONLY Copy to clipboard
t.Run("show foo with safecontent and autoclip enabled", func(t *testing.T) {
require.NoError(t, act.cfg.Set("", "show.autoclip", "true"))
require.NoError(t, act.cfg.Set("", "show.safecontent", "true"))
c := gptest.CliCtx(ctx, t, "foo")
require.NoError(t, act.Show(c))
assert.Contains(t, stderrBuf.String(), "WARNING")
assert.NotContains(t, stdoutBuf.String(), "secret")
stdoutBuf.Reset()
})
}

func TestShowHandleRevision(t *testing.T) {
Expand Down

0 comments on commit c4dc849

Please sign in to comment.