Excerpt generation misses first character

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Low
    • 3.2
    • Affects Version/s: 3.0
    • Component/s: None

      I've been having problems with CEO.getExcerpt() and it stripping the first character, so I decided to go on a hunt for the cause of it and I found this ... looks like someone forgot that in java both arrays and strings start at 0

      public static String summariseWithoutStrippingWikiCharacters(String content)
         {
             if (!TextUtils.stringSet(content))
                 return content;
      
             StringTokenizer st = new StringTokenizer(content, " ");
      
             if (st.countTokens() == 1)  //if it's but one word, exceeding 50 char.s,
             {                           //the length should be 46, plus a trailing space and ellipse.
                 if (content != null && content.length() > 50)
                 {
                     content = content.substring(1, 46);
                     content = content.concat(" ...");
                 }
             }
             else if (content != null && content.length() > 255)
             {
                 content =  TextUtils.trimToEndingChar(content, 251) + "...";
             }
      
             return content;
         }
      

      content = content.substring(1, 46);

      should probably be

      content = content.substring(0, 46);

              Assignee:
              Ryan
              Reporter:
              Alain Moran
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: