Page MenuHomePhabricator

[[|page]] style context link may forget to include namespace name
Open, MediumPublic

Description

Code says:

  1. Context links: [[|name]] and [[name (context)|]] $tc = '[' . Title::legalChars() . ']'; $nc = '[ _0-9A-Za-z\x80-\xff-]'; # Namespaces can use non-ascii!
  2. ... omitted ...

    $t = $this->mTitle->getText(); $m = array(); if ( preg_match( "/^($nc+:|)$tc+?( \\($tc+\\))$/", $t, $m ) ) { $text = preg_replace( $p2, "[[$m[1]\\1$m[2]|\\1]]", $text ); } elseif ( preg_match( "/^($nc+:|)$tc+?(, $tc+|)$/", $t, $m ) && "$m[1]$m[2]" != '' ) { $text = preg_replace( $p2, "[[$m[1]\\1$m[2]|\\1]]", $text ); } else {
    1. if there's no context, don't bother duplicating the title $text = preg_replace( $p2, '[[\\1]]', $text ); }

In 'if' and 'elseif' line, regexes begins with ($nc+:|) so I guess the original author intended to include namespace name automatically, but $t = $this->mTitle->getText(); should be written as $t = $this->mTitle->getPrefixedText(); in this case.


Version: unspecified
Severity: normal

Details

Reference
bz40162

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 12:47 AM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz40162.
bzimport added a subscriber: Unknown Object (MLST).