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

User fullname or course shortname with double quote breaks forum emails

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0, 3.1
    • Fix Version/s: 3.0.3
    • Component/s: Forum
    • Labels:
    • Testing Instructions:
      Hide
      1. Purge caches
      2. Run unit tests
      3. Modify your user, course, and activity to have full names including characters:
        1. '
        2. "
          ## {{ foo }}
        3. \
          ## >
        4. <
      4. Send some forum posts and run cron
        ## Confirm that all messages appear with the correct values (don't forget to check HTML + Text version + Digests)
      5. Add the attached test.mustache to lib/templates and purge caches
      6. Open the template library and find the template
        1. Confirm that the template renders correctly
      7. Modify the template to remove the commented out call to str + purge caches
      8. Refresh the template page
      9. Find the template and open it
        1. Confirm that you get an error (the unquoted json breaks)
      10. Place the attached test.php into the root and run it with the CLI
        1. Confirm that the first string fails to render correctly, whilst the second renders correctly
      Show
      Purge caches Run unit tests Modify your user, course, and activity to have full names including characters: ' " ## {{ foo }} \ ## > < Send some forum posts and run cron ##  Confirm that all messages appear with the correct values (don't forget to check HTML + Text version + Digests) Add the attached test.mustache to lib/templates and purge caches Open the template library and find the template Confirm that the template renders correctly Modify the template to remove the commented out call to str + purge caches Refresh the template page Find the template and open it Confirm that you get an error (the unquoted json breaks) Place the attached test.php into the root and run it with the CLI Confirm that the first string fails to render correctly, whilst the second renders correctly
    • Affected Branches:
      MOODLE_30_STABLE, MOODLE_31_STABLE
    • Fixed Branches:
      MOODLE_30_STABLE
    • Pull Master Branch:
      MDL-52136-master

      Description

      While creating some tests for MDL-52126 I detected that sometimes there were some placeholders in the resulting email body not being replaced. Example of borked results with both user lastname and course shortname having a double quote:

      101'" -> Forums -> Moodle Forum'" -> Hello Moodle'" 
      http://www.example.com/moodle/mod/forum/discuss.php?d=285000
      Hello Moodle'"
      by {$a->name} - {$a->date}
      ---------------------------------------------------------------------
      Welcome to Moodle'"
       
      Attachment example.txt:
      http://www.example.com/moodle/pluginfile.php/237006/mod_forum/attachment/286000/example.txt
       
      ---------------------------------------------------------------------
      This not is not a copy of a message posted on the {$a->coursename} website.
       
      To reply click on this not link: {$a->replylink}
      

      • I tested backporting the test to 29_STABLE and it worked there.
      • I tested without the double quotes and then it worked.

      To reproduce:

      A) method A: Create a user fullname or a course shortname containing double quotes and create a forum post with them. Mail (text or html) will arrive with those placeholders not replaced (in the text part of the multipart).
      B) method B: Uncomment the TODO lines in mod/forum/tests/mail_test.php and the test will fail showing the results above.

        Attachments

        1. test.mustache
          1 kB
        2. test.php
          0.3 kB

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/Mar/16