RedirectsTo function can return an html-encoded page title
Make robots for MediaWiki-powered sites!
Brought to you by:
code_driller
Imagine a wiki page with this title: Nuts & Bolts
A separate page can be redirected to that page with this syntax:
#REDIRECT [[Nuts %26 Bolts]]
This all works fine from the wiki perspective. However, when the RedirectsTo() function is executed on that redirect page, it returns "Nuts %26 Bolts". That is not a valid page title which breaks other things including the ResolveRedirect() function (because it tries to load the encoded page title which gets re-encoded and ends up with a 400 error).
I've experienced this on version 2.103. The code in 3.00 looks to have the same problem.
Suggest that RedirectsTo() should utilize HttpUtility.HtmlDecode() on the return value.
Actually,
HttpUtility.UrlDecoderather thanHttpUtility.HtmlDecode.Why would anyone use %26 instead of a & sign?
And I can't find any note in MediaWiki docs saying that this syntax is officially supported.
My suspicion is that a user copy/pasted the redirected-to page name out of their web browser address bar when entering the REDIRECT syntax. I have a few examples of this where the redirected-to page name is quite long, so it's feasible that the user would copy/paste rather than typing the entire name.
UrlDecode() will convert plus sign into space. And some percentage values may also be in danger. I don't feel it's right to call UrlDecode() in this case.