Bug 37048 - [PATCH] Prevent StringIndexOutOfBounds in Search
Summary: [PATCH] Prevent StringIndexOutOfBounds in Search
Status: NEEDINFO
Alias: None
Product: Lenya
Classification: Unclassified
Component: Lucene Integration (show other bugs)
Version: 1.2.4
Hardware: Other other
: P2 normal
Target Milestone: 1.2.6
Assignee: Lenya Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-12 16:40 UTC by solprovider
Modified: 2007-07-13 06:18 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description solprovider 2005-10-12 16:40:49 UTC
The error resulted from the space not being found so end = -1.
FILE: pubs/default/lenya/content/search/search-and-results.xsp
LINE# 515
ADD: the bounds checking code

                          if(slfield.length() > excerptOffset){
                             int start = 0;
                             int end = excerptOffset;
                             int half = excerptOffset/2;
                             if(first < half){
                                end = tmphtmlbody.indexOf(' ', excerptOffset);
                             }else{
                                start = tmphtmlbody.indexOf(' ', first - half);
                                end = tmphtmlbody.indexOf(' ', start +
excerptOffset);
                             }
//BEGIN: bounds checking (prevents StringIndexOutOfBounds if end = -1)
                            int tmphtmlbodylength = tmphtmlbody.length();
                            if(start > tmphtmlbodylength) start =
tmphtmlbodylength - excerptOffset;
                            if(start < 0) start = 0;
                            if(end < start) end = start + excerptOffset;
                            if(end > tmphtmlbodylength) end = tmphtmlbodylength;
//END: bounds checking
                             tmphtmlbody = tmphtmlbody.substring(start, end);
                          }
Comment 1 Antonio Gallardo 2007-03-21 22:06:10 UTC
Would you provide a patch?