Page MenuHomePhabricator

</noinclude> gets parsed within <pre></pre> in templates
Closed, ResolvedPublic

Description

</noinclude> gets parsed within <pre></pre> in templates, causing explanatory text to be transcluded into pages. In the following example, everything after </pre> and </noinclude> incorrectly gets transcluded wherever the template is used. The only workaround is to use <includeonly></includeonly> instead of <onlyinclude></onlyinclude>, which should not be necessary, and can cause problems if that is not how the template was designed.

This problem arises from the best-practice of encapsulating templatized category tags within no-include tags so that category transclusion will happen only once, not every time some other page uses the page that has a category template.

Here's the example:

<noinclude>
This is a category template for quickly adding pages to some categories. It is supposed to put the following into a page:

<pre>
<noinclude>
<!-- If this page is embedded within another page, noinclude will prevent that page from unintentionally becoming part of these categories -->
[[Category:Stuff]]
[[Category:Some other stuff]]
</noinclude>
</pre>
</noinclude>

Here's a sentence that's not supposed to be transcluded, but will be due to this bug.

<includeonly>
<noinclude>
<!-- If this page is embedded within another page, noinclude will prevent that page from unintentionally becoming part of these categories -->
[[Category:Stuff]]
[[Category:Some other stuff]]
</noinclude>
</includeonly>


Version: 1.16.x
Severity: normal

Details

Reference
bz29879

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 21 2014, 11:28 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz29879.
bzimport added a subscriber: Unknown Object (MLST).

Forgot to mention that the solution to this bug is to have the parser treat <pre> like <nowiki>, and ignore all tags found within, including the </noinclude> tags that the parser is tripping over in this example.

The parser doesn't handle nested tags as you would expect. When it finds an <noinclude> start tag, it just searches for the next matching </noinclude> end tag, without considering nested start tags. See bug 9428 for more examples with other tags.

*** This bug has been marked as a duplicate of bug 9428 ***