mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-25 15:32:52 +00:00
Use charset for content input stream
This commit is contained in:
parent
beb5ccf031
commit
80f4ab3cae
1 changed files with 19 additions and 5 deletions
|
@ -2917,15 +2917,29 @@ public class MessageHelper {
|
||||||
|
|
||||||
if (content instanceof String)
|
if (content instanceof String)
|
||||||
result = (String) content;
|
result = (String) content;
|
||||||
else if (content instanceof InputStream)
|
else if (content instanceof InputStream) {
|
||||||
|
// java.io.ByteArrayInputStream
|
||||||
// Typically com.sun.mail.util.QPDecoderStream
|
// Typically com.sun.mail.util.QPDecoderStream
|
||||||
result = Helper.readStream((InputStream) content);
|
if (BuildConfig.DEBUG && false)
|
||||||
else
|
warnings.add(content.getClass().getName());
|
||||||
|
Charset charset;
|
||||||
|
try {
|
||||||
|
String cs = h.contentType.getParameter("charset");
|
||||||
|
charset = (cs == null ? StandardCharsets.ISO_8859_1 : Charset.forName(cs));
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
Log.w(ex);
|
||||||
|
charset = StandardCharsets.ISO_8859_1;
|
||||||
|
}
|
||||||
|
result = Helper.readStream((InputStream) content, charset);
|
||||||
|
} else
|
||||||
result = content.toString();
|
result = content.toString();
|
||||||
} catch (IOException | FolderClosedException | MessageRemovedException ex) {
|
} catch (IOException | FolderClosedException | MessageRemovedException ex) {
|
||||||
throw ex;
|
throw ex;
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Log.w(ex);
|
Log.e(ex);
|
||||||
|
if (BuildConfig.TEST_RELEASE)
|
||||||
|
warnings.add(ex + "\n" + android.util.Log.getStackTraceString(ex));
|
||||||
|
else
|
||||||
warnings.add(Log.formatThrowable(ex, false));
|
warnings.add(Log.formatThrowable(ex, false));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue