Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-81953

Issue with sending unformatted text emails: double invocation of html_to_text() function

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.3.5
    • Email, Forum
    • MOODLE_403_STABLE

      Description:
      There is a bug when sending unformatted text emails if the format_text_email() function is called first, followed by email_to_user(). Both functions invoke html_to_text(), leading to issues with certain email content.

      Steps to Reproduce:

      Set the user's email preference (mailformat) to "unformatted text".
      Enable email notifications for forum posts and set it to "no digest".
      Create a forum post with the content "aaa &lt:bbb" (without a space between &lt: and bbb).
      Enable: "Send forum post notifications with no editing-time delay"

      Please note: i switched the semicolon in &lt: to a colon to prevent it beeing interpreted as <

      Expected Result:
      The email should be sent with the content "aaa <bbb".

      Actual Result:
      The email is sent with the content "aaa ". The first invocation of html_to_text() converts the message to "aaa <bbb". The second invocation misinterprets the "<" character as the beginning of an HTML tag, leading to the truncation of the message.

      Details:
      The double invocation occurs in in send_user_notifications.php as follows:

      1. renderer_textemail.php -> format_message_text() → format_text_email() -> html_to_text()
      2. message_send() → send_message() → send_message_to_processors() → call_processors() (in message_output_email.php) → email_to_user() → html_to_text()

            Unassigned Unassigned
            fdl Felix Di Lenarda
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 23 minutes
                23m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.