Skip to content

Commit 5d15e15

Browse files
committed
[BUGFIX] Fix password not saving to clipboard when AutoClip and SafeContent 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 <[email protected]>
1 parent 01b6ff1 commit 5d15e15

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

internal/action/show.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func (s *Action) showGetContent(ctx context.Context, sec gopass.Secret) (string,
273273
// everything but the first line.
274274
if config.Bool(ctx, "show.safecontent") && !ctxutil.IsForce(ctx) && ctxutil.IsShowParsing(ctx) {
275275
body := showSafeContent(sec)
276-
if IsAlsoClip(ctx) {
276+
if IsAlsoClip(ctx) || config.Bool(ctx, "show.autoclip"){
277277
return pw, body, nil
278278
}
279279

internal/action/show_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,18 @@ func TestShowAutoClip(t *testing.T) {
315315
stdoutBuf.Reset()
316316
stderrBuf.Reset()
317317
})
318+
319+
// gopass show foo with show.autoclip and show.safecontent true
320+
// -> ONLY Copy to clipboard
321+
t.Run("show foo with safecontent and autoclip enabled", func(t *testing.T) {
322+
require.NoError(t, act.cfg.Set("", "show.autoclip", "true"))
323+
require.NoError(t, act.cfg.Set("", "show.safecontent", "true"))
324+
c := gptest.CliCtx(ctx, t, "foo")
325+
require.NoError(t, act.Show(c))
326+
assert.Contains(t, stderrBuf.String(), "WARNING")
327+
assert.NotContains(t, stdoutBuf.String(), "secret")
328+
stdoutBuf.Reset()
329+
})
318330
}
319331

320332
func TestShowHandleRevision(t *testing.T) {

0 commit comments

Comments
 (0)