https://bz.apache.org/bugzilla/show_bug.cgi?id=68236
Bug ID: 68236 Summary: searchText(String,PositionInParagraph)@XWPFParagraph can wrongly reset BeginCharPos Product: POI Version: 5.3.x-dev Hardware: PC Status: NEW Severity: normal Priority: P2 Component: XWPF Assignee: dev@poi.apache.org Reporter: zhong...@pku.org.cn Target Milestone: --- The code is as follows: public TextSegment searchText(String searched, PositionInParagraph startPos) { ... int beginRunPos = 0, candCharPos = 0; for (int runPos = startRun; runPos < rArray.length; runPos++) { int beginTextPos = 0, beginCharPos = 0, textPos = 0, charPos; .... } beginTextPos and beginCharPos are in the loop and can be wrongly reset. NPOI fixed a similar bug: https://github.com/nissl-lab/npoi/commit/38cdadd3a67e59e6bede7f77996fbf048c5ffc7e In NPOI, the fixed code is as follows: public TextSegment SearchText(String searched, PositionInParagraph startPos){ ... int beginRunPos = 0, beginTextPos = 0, beginCharPos = 0,candCharPos = 0; for (int runPos = startRun; runPos < paragraph.GetRList().Count; runPos++){ int beginTextPos = 0, beginCharPos = 0, textPos = 0, charPos = 0; ... } -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For additional commands, e-mail: dev-h...@poi.apache.org