poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 59786] NPE at HMEFContentsExtractor.java:78
Date Mon, 04 Jul 2016 21:29:19 GMT

Sebb <sebb@apache.org> changed:

           What    |Removed                     |Added
             Status|NEEDINFO                    |NEW

--- Comment #7 from Sebb <sebb@apache.org> ---
[It's a bit of a pain building POI, because compile-ooxml-lite unexpectedly
runs loads of tests which don't always work for me, and even if they do, they
take a long time and produce lots of output]

I have now got "ant jar" to complete after commenting out the target

However it does not extract any body text; I get:

No message body found, POI/message.rtf not created
Extraction completed

A bit of experimentation shows that the new attribute has to be defined as a
new entry in MAPIProperty.java; if this is done it is then picked up by the
dumper as well. 

Using MAPIProperty.createCustom locally does not work; the method
getMessageMAPIAttribute returns null.

There's another change that needs to be done: if the body is an instance of
MAPIStringAttribute (as here) then writing the byte data directly to the file
produces an unreadable file which appears to be in UTF-16LE (no BOM).

Here's a very crude patch that works for me:

### Eclipse Workspace Patch 1.0
#P ApachePOI
--- src/scratchpad/src/org/apache/poi/hmef/extractor/HMEFContentsExtractor.java
   (revision 1751374)
+++ src/scratchpad/src/org/apache/poi/hmef/extractor/HMEFContentsExtractor.java
   (working copy)
@@ -95,7 +95,12 @@

         OutputStream fout = new FileOutputStream(dest);
         try {
-            fout.write(body.getData());
+            if (body instanceof MAPIStringAttribute) {
+                fout.write(((MAPIStringAttribute)
body).getDataString().getBytes()); // TODO fix the output charset
+            } else {
+                fout.write(body.getData());
+            }
         } finally {
@@ -104,13 +109,7 @@
     protected MAPIAttribute getBodyAttribute() {
         MAPIAttribute body =
         if (body != null) return body;
-        // See bug #59786 - we'd really like a test file to confirm if this
-        //  is the right properties + if this is truely general or not!
-        MAPIProperty uncompressedBody = 
-                MAPIProperty.createCustom(0x3fd9, Types.ASCII_STRING,
"Uncompressed Body");
-        // Return this uncompressed one, or null if that isn't their either
-        return message.getMessageMAPIAttribute(uncompressedBody);
+        return message.getMessageMAPIAttribute(MAPIProperty.WINMAILNEW);


Where the following was added to MAPIProperty.java:

   public static final MAPIProperty WINMAILNEW = // TODO fix the names!
      new MAPIProperty(0x3fd9, Types.UNICODE_STRING, "Uncompressed

You are receiving this mail because:
You are the assignee for the bug.

To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org

View raw message