Dearmor: transform IOExceptions into BadData properly

This commit is contained in:
Paul Schaub 2022-11-18 15:17:33 +01:00
parent 0e777de14f
commit 519fb891a1
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -28,6 +28,19 @@ public class DearmorCmd extends AbstractSopCmd {
String errorMsg = getMsg("sop.error.input.stdin_not_openpgp_data");
throw new SOPGPException.BadData(errorMsg, e);
} catch (IOException e) {
String msg = e.getMessage();
if (msg == null) {
throw new RuntimeException(e);
}
String errorMsg = getMsg("sop.error.input.stdin_not_openpgp_data");
if (msg.equals("invalid armor") ||
msg.equals("invalid armor header") ||
msg.equals("inconsistent line endings in headers") ||
msg.startsWith("unable to decode base64 data")) {
throw new SOPGPException.BadData(errorMsg, e);
}
throw new RuntimeException(e);
}
}