1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-09 18:29:39 +02:00

SOP armor: catch IOException during inspection of data

This commit is contained in:
Paul Schaub 2025-07-04 17:35:27 +02:00
parent d1826eb961
commit 4a4f85767a
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -14,6 +14,7 @@ import org.pgpainless.util.ArmoredOutputStreamFactory
import sop.Ready import sop.Ready
import sop.exception.SOPGPException import sop.exception.SOPGPException
import sop.operation.Armor import sop.operation.Armor
import java.io.IOException
/** Implementation of the `armor` operation using PGPainless. */ /** Implementation of the `armor` operation using PGPainless. */
class ArmorImpl : Armor { class ArmorImpl : Armor {
@ -26,8 +27,14 @@ class ArmorImpl : Armor {
val bufferedOutputStream = BufferedOutputStream(outputStream) val bufferedOutputStream = BufferedOutputStream(outputStream)
// Determine the nature of the given data // Determine the nature of the given data
val openPgpIn = OpenPgpInputStream(data) val openPgpIn = OpenPgpInputStream(data, false).apply {
openPgpIn.reset() try {
inspectBuffer()
} catch (e: IOException) {
// ignore
}
reset()
}
if (openPgpIn.isAsciiArmored) { if (openPgpIn.isAsciiArmored) {
// armoring already-armored data is an idempotent operation // armoring already-armored data is an idempotent operation