Page MenuHomePhabricator

Template transclusion in #interwikilink: causes fatal crash
Closed, ResolvedPublicPRODUCTION ERROR

Description

Steps to replicate the issue:

  • Open any page on dewiki for source code editing.
  • Insert {{#interwikilink:rfc|1{{Zeichen*|#}}appendix-I|1}}
  • Show preview.
  • This is similar to [[rfc:1#appendix-I]]
  • Template:Zeichen* is a masking template, which is not necessary here.
  • Introduced by error, same goes with Template:char
  • Actually no masking nor escaping is necessary. {{#interwikilink:rfc|1#appendix-I|1}} already works correctly.

What happens?:

  • Always crashing with some [44c45e45-ced7-4eb2-8ad5-9974e0c34f6a] 2024-12-11 13:14:15: Fataler Ausnahmefehler des Typs „Wikimedia\Assert\ParameterAssertionException
  • Reproducable on various pages, with various templates and reduced wikitext to one line as mentioned.
  • Template parameters are no problem at all and will be replaced by value correctly.

What should have happened instead?:

  • Preview should work normally.
  • Usage of templates to generate current path shall be possible.

Event Timeline

For the input {{#interwikilink:rfc|1{{Zeichen*|#}}appendix-I|1}}. The template actually outputs something like this

{{#interwikilink:rfc|1
    1. appendix-I|1}}

There's a new line at the beginning of the template output because the first character is #, and subsequently that starts a list item. The combination makes an invalid title, although it shouldn't crash this way.

Restricted Application changed the subtype of this task from "Bug Report" to "Production Error". · View Herald TranscriptDec 11 2024, 3:16 PM

Change #1102328 had a related patch set uploaded (by Ammarpad; author: Ammarpad):

[mediawiki/core@master] parser: User TitleParser to safely create TitleValue

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

For the input {{#interwikilink:rfc|1{{Zeichen*|#}}appendix-I|1}}. The template actually outputs something like this

{{#interwikilink:rfc|1
    1. appendix-I|1}}

There's a new line at the beginning of the template output because the first character is #, and subsequently that starts a list item. The combination makes an invalid title, although it shouldn't crash this way.

Arrrgh, yeah, sorry, that is the bloody *#;: behaviour of template transclusion.

However, the resulting page should have been regular output and perhaps a mistake or error message rather than Wikimedia\Assert\ParameterAssertionException error page, if a newline happens to occur in parameter value. I guess this will be remedied by the recent patch.

Change #1102328 merged by jenkins-bot:

[mediawiki/core@master] parser: Handle invalid titles gracefully in parser functions

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