Page MenuHomePhabricator

Page Forms: `pre`tagged templates are not ignored and can cause a memory leak issue
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • add parameter |multiple to for template tag on the form
  • surround a placed template with pre tags
  • place any text before the pre tag
  • edit the Page using Edit with form tab or use #formlink: to add/change entries

Form:

{{{for template|Test|multiple|add button text=Add another entry}}}
{| class="formtable"
! First parameter:
| {{{field|ParameterFirst|mandatory}}}
|-
! Second parameter:
| {{{field|ParameterSecond|mandatory}}}
|}
{{{end template}}}

{{{standard input|save}}}{{{standard input|cancel}}}

Page:

This is a test page
<pre>
{{Test
|ParameterFirst=test
|ParameterSecond=test
}}
</pre>

{{Test
|ParameterFirst=test 2
|ParameterSecond=test 2
}}

What happens?:
Side stuck at loading and throws a HTML 500 error.

Detailed debug information:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 60818080 bytes) in /var/lib/mediawiki/extensions/PageForms/includes/PF_FormPrinter.php on line 1835
  • When parameter |multiple is not added to the form, the first entry will be skipped and it don't runs into the memory issue.
  • When no text is placed before the pre tag it will treat the tagged entry like a normal one instead of ignoring it. It doesn't matter if parameter |multiple is added on the form, or not. In both cases it will recognize the pre tagged template as a valid entry.

What should have happened instead?:
Templates surrounded by pre tags should be recognised as valid entries by a form.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

MediaWiki: 1.43.0
PHP: 8.3.6 (apache2handler)
ICU: 74.2
MariaDB: 10.11.13-MariaDB-0ubuntu0.24.04.1
Lua: 5.1.5
Pygments: 2.17.2

Page Forms: 6.0.1 (1fa1489)

Other information (browser name/version, screenshots, etc.):
Browser: Firefox, Chrome

Event Timeline

Change #1247059 had a related patch set uploaded (by Dumbledore; author: Dumbledore):

[mediawiki/extensions/PageForms@master] Improve template detection logic by stripping unparsed text to prevent infinite recursion

https://gerrit.wikimedia.org/r/1247059

Hi @Gorasuhl

I have raised a patch for this task. kindly review it.

I would not necessarily expect bug reporters (instead of developers) to review patches

Change #1247059 merged by jenkins-bot:

[mediawiki/extensions/PageForms@master] Improve template detection logic by stripping unparsed text to prevent infinite recursion

https://gerrit.wikimedia.org/r/1247059