poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 49936] New: [Patch] java.lang.StringIndexOutOfBoundsException in org.apache.poi.hwpf.usermodel.HeaderStories
Date Thu, 16 Sep 2010 00:14:24 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=49936

           Summary: [Patch] java.lang.StringIndexOutOfBoundsException in
                    org.apache.poi.hwpf.usermodel.HeaderStories
           Product: POI
           Version: 3.7-dev
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HWPF
        AssignedTo: dev@poi.apache.org
        ReportedBy: ssmeets@ravn.co.uk


Created an attachment (id=26030)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=26030)
patch

Hi,

For some reason I have some Word documents that have a header/footer that
causes the following StringIndexOutOfBoundsException:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String
index out of range: -1
    at java.lang.String.substring(String.java:1937)
    at
org.apache.poi.hwpf.usermodel.HeaderStories.getAt(HeaderStories.java:162)
    at
org.apache.poi.hwpf.usermodel.HeaderStories.getFirstHeader(HeaderStories.java:87)
    at
org.apache.poi.hwpf.extractor.WordExtractor.getHeaderText(WordExtractor.java:177)
    at com.ravn.test.poi.MSDocTester.parse(MSDocTester.java:28)
    at com.ravn.test.Tester.main(Tester.java:17)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)

After investigation it turns out that prop.getEnd() was smaller then
prop.getStart() in one case and in the other case both prop.getStart() and
prop.getEnd() were bigger then headerStories.text().length. Therefore I
implemented two additional checks in the HeaderStories.java in the getAt
method, see attached patch. Could this be added to the next release if
approved?

Thanks in advance,
Sjoerd

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Mime
View raw message