Moodle
  1. Moodle
  2. MDL-19107

HTML entities not decoded in emailed message subject

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9, 1.9.1, 1.9.2, 1.9.3, 1.9.4
    • Fix Version/s: 1.9.7
    • Component/s: Messages
    • Labels:
      None
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE
    • Rank:
      31716

      Description

      When a user send a message to another user an email is sent with the subject taken form the first line of the message. What if that line has special html characters? The bug first appeared with quotations being shown in the subject of the mail as follows:

      "Hi Susan i would like to"

      In order to solve this bug I propose to use html_entity_decode() php function. The code would be as follows:
      In /message/lib.php on line 975:

      $messagesubject = preg_replace('/\s+/', ' ', strip_tags($message)); // make sure it's all on one line

      $messagesubject = html_entity_decode($messagesubject);

      $messagesubject = message_shorten_message($messagesubject, 30).'...';

        Activity

        Hide
        Andrew Davis added a comment -

        Resolved in 1.9. Added html_entity_decode to convert things like " back to regular characters and also strip_tags to pull html tags liks <b> and <p> out of the email subject line.

        2.0 email code doesn't have this issue.

        Show
        Andrew Davis added a comment - Resolved in 1.9. Added html_entity_decode to convert things like " back to regular characters and also strip_tags to pull html tags liks <b> and <p> out of the email subject line. 2.0 email code doesn't have this issue.
        Hide
        Martin Dougiamas added a comment -

        Andrew, don't forget to set the MOODLE_19_MERGED tag on the 1.9 branch even if a merge wasn't necessary.

        Show
        Martin Dougiamas added a comment - Andrew, don't forget to set the MOODLE_19_MERGED tag on the 1.9 branch even if a merge wasn't necessary.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: