diff --git a/pgpainless-sop/src/main/kotlin/org/pgpainless/sop/ArmorImpl.kt b/pgpainless-sop/src/main/kotlin/org/pgpainless/sop/ArmorImpl.kt index be2f272f..cf2c81df 100644 --- a/pgpainless-sop/src/main/kotlin/org/pgpainless/sop/ArmorImpl.kt +++ b/pgpainless-sop/src/main/kotlin/org/pgpainless/sop/ArmorImpl.kt @@ -15,6 +15,7 @@ import org.pgpainless.util.ArmoredOutputStreamFactory import sop.Ready import sop.exception.SOPGPException import sop.operation.Armor +import java.io.IOException /** Implementation of the `armor` operation using PGPainless. */ class ArmorImpl(private val api: PGPainless) : Armor { @@ -27,8 +28,15 @@ class ArmorImpl(private val api: PGPainless) : Armor { val bufferedOutputStream = BufferedOutputStream(outputStream) // Determine the nature of the given data - val openPgpIn = OpenPGPAnimalSnifferInputStream(data) - openPgpIn.reset() + + val openPgpIn = OpenPGPAnimalSnifferInputStream(data, false).apply { + try { + inspectBuffer() + } catch (e: IOException) { + // ignore + } + reset() + } if (openPgpIn.isAsciiArmored) { // armoring already-armored data is an idempotent operation