Page MenuHomePhabricator

Parser functions cannot control their output
Open, LowPublic

Description

Author: conrad.irwin

Description:
At the moment some parser functions/variables output is partially escaped and partially treated as wikitext (using wfEscapeWikiText). This breaks both parsing and the use of the output of one variable as input to another, see:

{{PAGENAME}} on [[*]]
{{urlencode:{{PAGENAME}}}} on [[&]]

The solution I propose is to add a new class of UNIQ tags to the parser. Extensions can "return $parser->armouredText( $text );" where they currently "return wfEscapeWikiText( $text )".

The parser should have two replacements for each armouredText, when calling further parser functions, it replaces it with the original; when outputting, it replaces it with the escaped version (at the same time <nowiki> is re-expanded). The ugliness is that it will require several changes to allow armouredText UNIQs to be part of links/template names/magic words.

A much hackier alternatively is an inclusion prefix or two (cf. msg: int: msgnw:) that could be added such that {{plain:PAGENAME}} returns the unescaped version, while {{armour:PAGENAME}} puts it into one of the existing nowiki UNIQs - but this really shouldn't be exposed to users.


Version: unspecified
Severity: normal

Details

Reference
bz22880

Event Timeline

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

Isn’t this just a duplicate of bug #12974?

conrad.irwin wrote:

Fixing this would fix some (but not all) of the problems caused by bug 12974, and vice versa, but they are not duplicates.