Page MenuHomePhabricator

Handle parser functions returning raw html
Closed, DuplicatePublic

Description

Parsoid uses the expandtemplates API call to expand parser functions -- but some parser functions can return raw HTML.
In this case, a call to expand x{{#rawhtml2:<a href="http://mahalo.com/">Mahalo</a>}}y'''z''' like:

http://localhost/~cananian/mediawiki/api.php?action=expandtemplates&format=json&text=x%7B%7B%23rawhtml2%3A%3Ca%20href%3D%22http%3A%2F%2Fmahalo.com%2F%22%3EMahalo%3C%2Fa%3E%7D%7Dy'''z'''&prop=wikitext%7Ccategories%7Cproperties%7Cmodules%7Cjsconfigvars

will return:

{
    "expandtemplates": {
        "wikitext": "x<a href=\"http://mahalo.com/\">Mahalo</a>y'''z'''",
        "modules": [],
        "modulescripts": [],
        "modulestyles": [],
        "jsconfigvars": {}
    }
}

and this will be mangled by parsoid, since the return value is treated as wikitext and <a> is not valid wikitext.

We probably need to add a new core API specifically for "expand parser function" (not surrounded by wikitext), which can return the isHTML flag from the parser function.

See also: T178584: Remove insertStripItem workarounds from parser function implementations

Event Timeline

Arlolra triaged this task as Medium priority.Dec 11 2017, 10:56 PM

Even though this is older than T279094, I am closing this as a dupe of the other one because that other one has more activity and notes.