PGP: retry with trim

This commit is contained in:
M66B
2024-07-26 08:29:18 +02:00
parent 4f3d58f42c
commit b72486752f
2 changed files with 57 additions and 5 deletions

View File

@@ -88,6 +88,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FilterInputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -6130,6 +6131,47 @@ public class MessageHelper {
}
}
static class StripStream extends FilterInputStream {
protected StripStream(InputStream in) {
super(in);
}
@Override
public int read() throws IOException {
int b = super.read();
if (b == ' ') {
super.mark(1000);
while (true) {
b = super.read();
if (b != ' ') {
if (b == '\r' || b == '\n')
return b;
else {
super.reset();
return ' ';
}
}
}
} else
return b;
}
@Override
public int read(byte[] b) throws IOException {
for (int i = 0; i < b.length; i++) {
b[i] = (byte) read();
if (b[i] < 0)
return i;
}
return b.length;
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
throw new UnsupportedOperationException();
}
}
static class CanonicalizingStream extends FilterOutputStream {
private OutputStream os;
private int content;