Hi Christian,

I think the problem is in this code.  All the comments and the bounds
checking code are new.  The file is
{pub}/lenya/content/search/search-and-results.xsp

//first = indexOf(earliest search term found) or -1 if not found.
//excerptOffset = search parameter, default 100.
//slfield = String (text of BODY)
//tmphtmlbody = same as tmphtmlbody with '~' before and after each search term.

                         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);
                             }
//start should be 0 or first - half
//end should be the first space after either excerptOffset or start +
excerptOffset
//BEGIN: Add bounds checking:
                             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);
                          }

It seems to break on the substring().  Please try adding the bounds
checking code.  The resulting excerpt might be wrong, but hopefully it
will not error.  Let me know what happens.  I'll do a more thorough
analysis tomorrow.

solprovider

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to