mirror of https://github.com/M66B/FairEmail.git
Prevent bare linefeeds
This commit is contained in:
parent
8d90b2d471
commit
f97592345e
|
@ -163,7 +163,9 @@ import org.openintents.openpgp.OpenPgpError;
|
||||||
import org.openintents.openpgp.util.OpenPgpApi;
|
import org.openintents.openpgp.util.OpenPgpApi;
|
||||||
import org.w3c.dom.css.CSSStyleSheet;
|
import org.w3c.dom.css.CSSStyleSheet;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
@ -3679,19 +3681,25 @@ public class FragmentCompose extends FragmentBase {
|
||||||
|
|
||||||
File file = attachment.getFile(context);
|
File file = attachment.getFile(context);
|
||||||
|
|
||||||
if (OpenPgpApi.ACTION_DETACHED_SIGN.equals(data.getAction())) {
|
// // 550 5.6.11 SMTPSEND.BareLinefeedsAreIllegal; message contains bare linefeeds, which cannot be sent via DATA and receiving system does not support BDAT (failed)
|
||||||
byte[] bytes = result.getByteArrayExtra(OpenPgpApi.RESULT_DETACHED_SIGNATURE);
|
// https://learn.microsoft.com/en-us/exchange/troubleshoot/email-delivery/ndr/fix-error-code-550-5-6-11-in-exchange-online
|
||||||
Log.i("Writing " + file + " size=" + bytes.length);
|
try (InputStream is = new BufferedInputStream(
|
||||||
try (OutputStream out = new FileOutputStream(file)) {
|
OpenPgpApi.ACTION_DETACHED_SIGN.equals(data.getAction())
|
||||||
out.write(bytes);
|
? new ByteArrayInputStream(result.getByteArrayExtra(OpenPgpApi.RESULT_DETACHED_SIGNATURE))
|
||||||
|
: new FileInputStream(output))) {
|
||||||
|
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
|
||||||
|
int b;
|
||||||
|
while ((b = is.read()) >= 0)
|
||||||
|
if (b != '\r') {
|
||||||
|
if (b == '\n')
|
||||||
|
os.write('\r');
|
||||||
|
os.write(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
db.attachment().setDownloaded(attachment.id, (long) bytes.length);
|
|
||||||
} else {
|
|
||||||
Log.i("Writing " + file + " size=" + output.length());
|
|
||||||
Helper.copy(output, file);
|
|
||||||
db.attachment().setDownloaded(attachment.id, file.length());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
db.attachment().setDownloaded(attachment.id, file.length());
|
||||||
|
|
||||||
db.setTransactionSuccessful();
|
db.setTransactionSuccessful();
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
|
|
Loading…
Reference in New Issue