Moodle
  1. Moodle
  2. MDL-11769

Use of shorten_text() on question name, not reliable

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8.3, 1.9, 2.0
    • Fix Version/s: 1.8.4, 1.9, 2.0
    • Component/s: Questions
    • Labels:
      None
    • Database:
      PostgreSQL
    • Affected Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE
    • Rank:
      30069

      Description

      When the question name is derived from the question text, it is protected from excessive length using the shorten_text() function, as this only splits on word boundaries it is not guaranteed to bring the string in within the database field size for the name. This (particularly on Postgres) can be a case of database errors. Recommend adding a second substr() call to protect the field.

        Activity

        Hide
        Howard Miller added a comment -

        ....and check for strip_tags() too.

        Show
        Howard Miller added a comment - ....and check for strip_tags() too.
        Hide
        Howard Miller added a comment -

        shorten_text() is now set to 200 characters, but a substr() is then done to confirm 250 characters for GIFT names. A strip_tags() is now also applied to the name text.

        Show
        Howard Miller added a comment - shorten_text() is now set to 200 characters, but a substr() is then done to confirm 250 characters for GIFT names. A strip_tags() is now also applied to the name text.

          People

          • Assignee:
            Howard Miller
            Reporter:
            Howard Miller
            Tester:
            Nobody
            Participants:
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: