Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-17659

Excerpt generation misses first character

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Low
    • 3.2
    • 3.0
    • None

    Description

      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);

      Attachments

        Activity

          People

            rthomas@atlassian.com RyanA
            9fcfb21963e3 Alain Moran
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: