You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2010/09/16 02:14:24 UTC
DO NOT REPLY [Bug 49936] New: [Patch]
java.lang.StringIndexOutOfBoundsException in
org.apache.poi.hwpf.usermodel.HeaderStories
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
DO NOT REPLY [Bug 49936] [Patch]
java.lang.StringIndexOutOfBoundsException in
org.apache.poi.hwpf.usermodel.HeaderStories
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49936
--- Comment #4 from ssmeets@ravn.co.uk 2010-09-16 13:35:11 EDT ---
Attached the two files it was failing on. For some reason I can not get JUnit
testing not working, but I belive this should be the test cases:
headerSubStringErr = HWPFTestDataSamples.openSampleFile("Case1.doc");
headerSubStringErr1 = HWPFTestDataSamples.openSampleFile("Case2.doc");
public void testHeader() {
HeaderStories hs = new HeaderStories(headerSubStringErr);
assertEquals("",hs.getHeaderText());
}
public void testHeader1() {
HeaderStories hs = new HeaderStories(headerSubStringErr1);
assertEquals("",hs.getHeaderText());
}
--
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
DO NOT REPLY [Bug 49936] [Patch]
java.lang.StringIndexOutOfBoundsException in
org.apache.poi.hwpf.usermodel.HeaderStories
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49936
Nick Burch <ni...@alfresco.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEEDINFO |RESOLVED
Resolution| |FIXED
--- Comment #5 from Nick Burch <ni...@alfresco.com> 2010-09-17 10:14:30 EDT ---
Thanks for the patch and test files. Fix, along with a unit test committed in
r998146.
--
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
DO NOT REPLY [Bug 49936] [Patch]
java.lang.StringIndexOutOfBoundsException in
org.apache.poi.hwpf.usermodel.HeaderStories
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49936
--- Comment #2 from ssmeets@ravn.co.uk 2010-09-16 13:33:42 EDT ---
Created an attachment (id=26033)
--> (https://issues.apache.org/bugzilla/attachment.cgi?id=26033)
WordDoc for Junit test
--
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
DO NOT REPLY [Bug 49936] [Patch]
java.lang.StringIndexOutOfBoundsException in
org.apache.poi.hwpf.usermodel.HeaderStories
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49936
Nick Burch <ni...@alfresco.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |NEEDINFO
--- Comment #1 from Nick Burch <ni...@alfresco.com> 2010-09-16 12:08:43 EDT ---
Any chance you could upload a problem word document that currently breaks? This
can then be used as the basis of a unit test to be committed with this patch
--
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
DO NOT REPLY [Bug 49936] [Patch]
java.lang.StringIndexOutOfBoundsException in
org.apache.poi.hwpf.usermodel.HeaderStories
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49936
--- Comment #3 from ssmeets@ravn.co.uk 2010-09-16 13:34:53 EDT ---
Created an attachment (id=26034)
--> (https://issues.apache.org/bugzilla/attachment.cgi?id=26034)
WordDoc for Junit Test 2
--
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