Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-1887

searchResultSnippet should replace <br> tags with white space instead of removing them completly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Minor
    • None
    • 3.0.5
    • None
    • None
    • Any

    Description

      The stripHtmlTags() method of the SearchResultSnippetTag class should not simply strip all HTML tags. Line breaks should be replaced by white space.This can be simply done by searching & replacing line break tags first, then stripping all remaining HTML tags:

      protected String stripHtmlTags(String resultString) {
      resultString = resultString.replaceAll("
      <br>", " ");
      resultString = resultString.replaceAll("
      <br/>", " ");
      resultString = resultString.replaceAll("
      <br />", " ");
      resultString = resultString.replaceAll("
      <BR>", " ");
      resultString = resultString.replaceAll("
      <BR/>", " ");
      resultString = resultString.replaceAll("
      <BR />", " ");
      return resultString.replaceAll("\\<(.?\\s)*
      >", StringUtils.EMPTY); //$NON-NLS-1$
      }

      I'm sure one could also achive the same with a single regex statement.

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              Unassigned Unassigned
              will Will Scheidegger
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Bug DoR
                  Task DoD