Moodle
  1. Moodle
  2. MDL-20537

shorten_text sometimes omits close tags

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.5
    • Fix Version/s: 1.9.7
    • Component/s: Libraries
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE
    • Rank:
      31917

      Description

      The core function shorten_text is supposed to close any HTML tags that it cuts off. However this only occurs sometimes, depending on the parameters. The sequence of events that occurs is:

      • Function divides input into blocks starting with each tag (open/close/empty)
      • Loops through these input 'lines' until there is more text than the shorten_text allows

      At this point, any tags that are not closed (ie that would be closed in future 'lines') are safe - they will be closed.

      • Goes back looking for a space or suitable breakpoint to chop the text so it is under the limit

      During this process close tags may be chopped off. These are not re-added.

        Issue Links

          Activity

          Hide
          Sam Marshall added a comment -

          Note: I already committed a minor change to fix whitespace. This has the side effect of meaning the code is the same in HEAD.

          Here is a patch that contains the fix and a small selection of unit tests that indicate I probably haven't broken everything.

          The patch applies to 1.9 and 2.0

          Tim, could you confirm your review please?

          Show
          Sam Marshall added a comment - Note: I already committed a minor change to fix whitespace. This has the side effect of meaning the code is the same in HEAD. Here is a patch that contains the fix and a small selection of unit tests that indicate I probably haven't broken everything. The patch applies to 1.9 and 2.0 Tim, could you confirm your review please?
          Hide
          Sam Marshall added a comment -

          Because the stable branch is currently in freeze for 19.6, if this is reviewed OK, I will commit it only to HEAD until after 1.9.6.

          Show
          Sam Marshall added a comment - Because the stable branch is currently in freeze for 19.6, if this is reviewed OK, I will commit it only to HEAD until after 1.9.6.
          Hide
          Tim Hunt added a comment -

          Sam, 1.9.6 is now tagged. You can commit this any time.

          Show
          Tim Hunt added a comment - Sam, 1.9.6 is now tagged. You can commit this any time.
          Hide
          Sam Marshall added a comment -

          Thanks Tim. Now committed to 1.9 branch (and tagged merged) as well as HEAD.

          Unit test (on 1.9) passes.

          (I had to faff around with the patch... if we used git here I would've saved about 45 minutes, grr...)

          Show
          Sam Marshall added a comment - Thanks Tim. Now committed to 1.9 branch (and tagged merged) as well as HEAD. Unit test (on 1.9) passes. (I had to faff around with the patch... if we used git here I would've saved about 45 minutes, grr...)
          Hide
          Andrew Davis added a comment -

          fix and unit tests look good. closing.

          Show
          Andrew Davis added a comment - fix and unit tests look good. closing.

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: