Bug 62412 - XWPFParagraph.searchText returns null although the paragraph contains the searched value
Summary: XWPFParagraph.searchText returns null although the paragraph contains the sea...
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: 3.17-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-27 10:40 UTC by Florian Sommer
Modified: 2018-05-27 10:40 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Sommer 2018-05-27 10:40:40 UTC
The current Implementation of XWPFParagraph.searchText(...) is basically a buggy version of the KMP Algorithm to search text
(https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm)

Example:
Searched = "yoyoPlayer"
Text = "yoyoyoPlayer"
Result = null, expected = found at beginChar=2

The testcase, a lengthy explanation of the bug's cause and the fix are provided in this repo:

https://github.com/fsomme2s/apache-poi-bug57727

Go to test class 'YoyoPlayerTest' (test folder).
The fix is provided in class 'FixedParagraphSearchText' (main folder)

Note: In a second test case I also demonstrate the bug 57727, which is also fixed in the FixedParagraphSearchText class. Sorry for the mess