Given the following HTML:
<a rel="mw:WikiLink" href="./]] foo [[bar">Manual</a>
<a href="./]] foo [[bar">Manual</a>
I get [1]:
[[./]] foo [[bar|Manual]]
[./%5D%5D%20foo%20%5B%5Bbar Manual]
The one for external is acceptable (garbage in, garbage out), as it doesn't cause arbitrary wikitext to be passed through.
However the one for mw:WikiLink seems a bug to me. Although it is impossible to link to an invalid link in wikitext (not even with [[<nowiki>invalid </nowiki>]]), that is better than passing through arbitrary wikitext.
That way it at least roundtrips and doesn't mess up the document.
<a rel="mw:WikiLink" href="./]] foo [[bar">Manual</a>
Should serialize to something like:
[[<nowiki>]] foo [[bar</nowiki>|Manual]]
Which parses to:
<a rel="mw:WikiLink" href="./%5D%5D_foo_%5B%5Bbar" data-parsoid="{"stx":"piped","a":{"href":"./%5D%5D_foo_%5B%5Bbar"},"sa":{"href":"<nowiki>]] foo [[bar</nowiki>"},"dsr":[1,41,32,2]}">Manual</a>
[1] http://parsoid.wmflabs.org/_html/
Version: unspecified
Severity: normal