https://bz.apache.org/bugzilla/show_bug.cgi?id=64244

            Bug ID: 64244
           Summary: [PATCH] Fix exception from using applyFont for unicode
                    representation _xHHHH_
           Product: POI
           Version: 4.1.2-FINAL
          Hardware: PC
                OS: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: XSSF
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Created attachment 37107
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=37107&action=edit
Add testUtfDecode_withApplyFont and patch XSSFRichTextString.getFormatMap

If you use `applyFont()` for `XSSFRichString` having unicode representation
_xHHHH_ format, an IllegalArgumentException is thrown.
`testUtfDecode_withApplyFont` is a new test made by myself, also in the patch.

> Text length was 8 but the last format index was 20
> java.lang.IllegalArgumentException: Text length was 8 but the last format 
> index was 20
>       at 
> org.apache.poi.xssf.usermodel.XSSFRichTextString.buildCTRst(XSSFRichTextString.java:590)
>       at 
> org.apache.poi.xssf.usermodel.XSSFRichTextString.applyFont(XSSFRichTextString.java:157)
>       at 
> org.apache.poi.xssf.usermodel.XSSFRichTextString.applyFont(XSSFRichTextString.java:167)
>       at 
> org.apache.poi.xssf.usermodel.TestXSSFRichTextString.testUtfDecode_withApplyFont(TestXSSFRichTextString.java:269)
>       ...

So I modified `XSSFRichTextString.getFormatMap()` to sum length after
utf-decoded. Then the test and all tests are passed well.

Actually, I have an original xlsx file that makes this problem, but due to the
security reason, I can't share the file. I think someone can help making MWE.

-- 
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