Uploaded image for project: 'Sakai'
  1. Sakai
  2. SAK-35953

Exception thrown from inappropriate use of FormattedText.processFormattedText()

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: CLOSED
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.5.0, 2.5.2, 2.5.3, 2.5.4, 2.6.0
    • Fix Version/s: 2.6.1, 2.7.0
    • Labels:
      None
    • Previous Issue Keys:
      SAK-14153, SAM-747

      Description

      When I use FormattedText.processFormattedText() to process the input text. If the input is something like:

      b<a

      I got an "String index out of range" error:

      ERROR: String index out of range: 4 (2008-08-01 13:17:40,703 http-8080-Processor
      22_com.sun.faces.lifecycle.ApplyRequestValuesPhase)
      java.lang.StringIndexOutOfBoundsException: String index out of range: 4
      at java.lang.String.substring(String.java:1765)
      at org.sakaiproject.util.FormattedText.trimFormattedText(FormattedText.j
      ava:958)
      ...

      The reason is in trimFormattedText(), with the unbalanced '<', the variable pos gets increased beyond the length of the input string. If I fix this by catching the exception and return the original input string. Because <a is an HTML tag. It won't get displayed correctly. That is, I will only see b.

        Gliffy Diagrams

          Zeplin

            Attachments

              Issue Links

                Activity

                  People

                  Assignee:
                  jthapa Jasmine Thapa (Inactive)
                  Reporter:
                  ktsao Karen Tsao
                  Votes:
                  2 Vote for this issue
                  Watchers:
                  7 Start watching this issue

                    Dates

                    Created:
                    Updated:
                    Resolved:

                      Git Integration