Skip to content

Commit

Permalink
Fix sop dearmor on already-dearmored data
Browse files Browse the repository at this point in the history
  • Loading branch information
twiss committed Nov 8, 2024
1 parent 7bf39ff commit ba8be29
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmd/dearmor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ import (
// DearmorComm takes armored OpenPGP material from Std input and outputs the
// same material with ASCII-armoring removed.
func DearmorComm() error {
armorReader, err := armor.ArmorReader(os.Stdin)
inputReader, isArmored := armor.IsPGPArmored(os.Stdin)
if !isArmored {
// If already dearmored, output directly and return
_, err := io.Copy(os.Stdout, inputReader)
if err != nil {
return dearmErr(err)
}
return nil
}

armorReader, err := armor.ArmorReader(inputReader)
if err != nil {
return dearmErr(err)
}
Expand Down

0 comments on commit ba8be29

Please sign in to comment.