Last modified: 2008-08-11 08:58:42 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T17053, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 15053 - Redirect parsing is over-permissive; syntactically broken redirects are parsed as redirects to the wrong place.
Redirect parsing is over-permissive; syntactically broken redirects are parse...
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Redirects (Other open bugs)
unspecified
All All
: Normal minor with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
http://en.wikipedia.org/w/index.php?t...
: patch
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-08-06 01:35 UTC by Hesperian
Modified: 2008-08-11 08:58 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Patch to fix the problem (584 bytes, patch)
2008-08-06 14:37 UTC, Aryeh Gregor (not reading bugmail, please e-mail directly)
Details
Proposed patch (821 bytes, patch)
2008-08-06 14:52 UTC, Roan Kattouw
Details

Description Hesperian 2008-08-06 01:35:41 UTC
[http://en.wikipedia.org/w/index.php?title=Pinus_edulis&oldid=212833839 This] redirect should be parsed as horribly broken, not as a redirect to a category:

The text of that page is:
----
#REDIRECT [[Colorado Pinyon]

{{R from scientific name}}

[[Category:Symbols of New Mexico]]
----
i.e. the true target of the redirect is not properly closed. The text is syntactically incorrect, and should be parsed as such. Unfortunately, Mediawiki parses this as a redirect to [[:Category:Symbols of New Mexico]], which is completely unintuitive, and certainly not what was intended.
Comment 1 Aryeh Gregor (not reading bugmail, please e-mail directly) 2008-08-06 14:37:25 UTC
Created attachment 5126 [details]
Patch to fix the problem

This patch would fix the problem, which is quite a simple one.  However, it's not clear how much we want to tighten the parsing here.  This patch would rule out the following page text as well:

----
#REDIRECT

[[Colorado Pinyon]]
----

I don't know whether we want to.  People may be depending on this behavior.  Also, if we're tightening up redirect parsing, my patch doesn't go as far as it could.  It just requires that the link be on the same line, so this would still fail:

----
#REDIRECT [[Colorado Pinyon] {{R from scientific name}} [[Category:Symbols of New Mexico]]
----

A more complete patch would remove the magic word and then require the target link to be at the beginning of the line, after whitespace is stripped.  Is this desirable?  It could potentially break a lot of redirects.
Comment 2 Roan Kattouw 2008-08-06 14:41:51 UTC
(In reply to comment #1)
> A more complete patch would remove the magic word and then require the target
> link to be at the beginning of the line, after whitespace is stripped.  Is this
> desirable?  It could potentially break a lot of redirects.
> 
I'm working on a patch that does just that.
Comment 3 Roan Kattouw 2008-08-06 14:52:46 UTC
Created attachment 5127 [details]
Proposed patch

This patch requires that the link immediately follow #REDIRECT, but does allow it to be on a different line. That is, everything that matches:

#REDIRECT <whitespace> [[<valid title>]]

is a redirect. <whitespace> can contain newlines, and can also be nothing (so #REDIRECT[[Foo]] will also work).

To illustrate, I've tested the following examples:
#REDIRECT         [[Foo]]\n[[Category:Bar]]
    returns Foo
#REDIRECT[[Foo]]
    returns Foo
#REDIRECT\n[[Foo]]\n[[Category:Bar]]
    returns Foo
#REDIRECT [[Foo]\n[[Category:Bar]]
    returns null
Comment 4 Aryeh Gregor (not reading bugmail, please e-mail directly) 2008-08-06 16:27:51 UTC
Well, want to commit it?  It *might* break stuff, but it seems fairly unlikely.  *I've* never seen a redirect with non-whitespace between the magic word and the link, at least.
Comment 5 Roan Kattouw 2008-08-06 20:34:22 UTC
(In reply to comment #4)
> Well, want to commit it?  It *might* break stuff, but it seems fairly unlikely.
>  *I've* never seen a redirect with non-whitespace between the magic word and
> the link, at least.
> 

Committed in r38737
Comment 6 Hesperian 2008-08-06 23:31:07 UTC
Gosh you guys are fast. Thanks heaps for that.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links