moodle-filter_filtercodes icon indicating copy to clipboard operation
moodle-filter_filtercodes copied to clipboard

Bug: Filter circular reference leads to fatal error

Open tasosb opened this issue 1 year ago • 1 comments

Prerequisites

  • [X] I'm reporting the issue to the correct repository.
  • [X] I am running the latest version of this plugin (if not, please upgrade first).
  • [X] I checked the README.md and Wiki documentation but did not find my answer.
  • [X] I searched to make sure that this issue had not already been reported.
  • [X] I have, or I know someone who has, the ability and willingness to test the fix on a Moodle LMS-based site.
  • [X] I am submitting no more than one bug report per issue ticket (please do not submit multiple bugs in one issue ticket).
  • [X] I understand that support is provided by volunteer(s).

What happened?

The plugin doesn't account for possible circular references with certain tags.

For example, a teacher may rename their course to "Test course {coursename}". This will render the course unusable, as when the filter is applied, the course name will be converted "Test course Test course {coursename}" and so on. Moodle will raise a Fatal Error: Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 262144 bytes) in moodle311\lib\moodlelib.php on line 7301

Similarly, adding {coursesummary} to the summary of the course, will render the moodle mobile application unusable. In the website the summary of the course is visible only on the first page, but it has the front page context and the filter prints the site summary (as expected from the instructions). However, in the mobile app, the summary of the course is visible on the course page and thus has the course context, leading to a similar error as above.

What do you think should have happened?

The plugin should prevent possible circular references in the filters.

Steps to reproduce

  1. Login as a teacher
  2. Create a course with the name "Test course {coursename}"
  3. Save the course
  4. Try navigating to the course

Screenshots

No response

Moodle version

Moodle 3.11.11+ (Build: 20221201)

Installed Moodle UI Language packs.

  • [ ] English only
  • [ ] One or more other languages/regional dialects (specify below)
  • [ ] Other

If other language(s), please specify

No response

Workaround

No response

Additional information

No response

System information

No response

Code of Conduct

  • [X] I have read and agree to the project's code of conduct.

tasosb avatar Dec 14 '22 14:12 tasosb