https://issues.apache.org/bugzilla/show_bug.cgi?id=53109

             Bug #: 53109
           Summary: NameCommentRecord can not handle multibyte characters
           Product: POI
           Version: 3.8
          Platform: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: [email protected]
        ReportedBy: [email protected]
    Classification: Unclassified


Created attachment 28643
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28643
Testdata

The following exception has occurred when opening the file.

----

org.apache.poi.hssf.record.RecordInputStream$LeftoverDataException:
Initialisation of record 0x894 left 10 bytes remaining still to be read.
    at
org.apache.poi.hssf.record.RecordInputStream.hasNextRecord(RecordInputStream.java:156)
    at
org.apache.poi.hssf.record.RecordFactoryInputStream.nextRecord(RecordFactoryInputStream.java:231)
    at
org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:443)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:285)
    at
org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:88)

---
Error file has following conditions.

- Has named cell.
- Named cell has comment.
- Name of named cell or comment has multibyte characters.

I fixed NameCommentRecord as follows.

----
//Constructor.  NameCommentRecord(final RecordInputStream ris)
    if (in.readByte() == 0) {
        field_6_name_text = StringUtil.readCompressedUnicode(in,
field_4_name_length);
    } else {
        field_6_name_text = StringUtil.readUnicodeLE(in, field_4_name_length);
    }
    if (in.readByte() == 0) {
        field_7_comment_text = StringUtil.readCompressedUnicode(in,
field_5_comment_length);
    } else {
        field_7_comment_text = StringUtil.readUnicodeLE(in,
field_5_comment_length);
    }
---
So I can read file.
I think the serialize method have to change too.

Please check my changes.

regards.

Shunji Konishi

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to