When dumping a HMEF body that is a string not RTF, use a predictable encoding rather than whatever the property happened to have in the original file
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751386 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
28c437531e
commit
e4d673ddc3
@ -31,6 +31,7 @@ import org.apache.poi.hmef.attribute.MAPIRtfAttribute;
|
||||
import org.apache.poi.hmef.attribute.MAPIStringAttribute;
|
||||
import org.apache.poi.hsmf.datatypes.MAPIProperty;
|
||||
import org.apache.poi.hsmf.datatypes.Types;
|
||||
import org.apache.poi.util.StringUtil;
|
||||
|
||||
/**
|
||||
* A utility for extracting out the message body, and all attachments
|
||||
@ -95,7 +96,14 @@ public final class HMEFContentsExtractor {
|
||||
|
||||
OutputStream fout = new FileOutputStream(dest);
|
||||
try {
|
||||
fout.write(body.getData());
|
||||
if (body instanceof MAPIStringAttribute) {
|
||||
// Save in a predictable encoding, not raw bytes
|
||||
String text = ((MAPIStringAttribute)body).getDataString();
|
||||
fout.write(text.getBytes(StringUtil.UTF8));
|
||||
} else {
|
||||
// Save the raw bytes, should be raw RTF
|
||||
fout.write(body.getData());
|
||||
}
|
||||
} finally {
|
||||
fout.close();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user