https://bugzilla.wikimedia.org/show_bug.cgi?id=57762

Bartosz Dziewoński <matma....@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matma....@gmail.com

--- Comment #1 from Bartosz Dziewoński <matma....@gmail.com> ---
The current code for this is in WikitextContent, and the regex does look
stricter.

The regex itself was changed back in 2008, though, in r38737 by Roan (with a
reference to bug 15053), and made a bit more relaxed (accepting the colon) in
2008 too in r38974 by Brion.

----

The current code for reference:

public function getRedirectTarget() {
  global $wgMaxRedirects;
  if ( $wgMaxRedirects < 1 ) {
    // redirects are disabled, so quit early
    return null;
  }
  $redir = MagicWord::get( 'redirect' );
  $text = trim( $this->getNativeData() );
  if ( $redir->matchStartAndRemove( $text ) ) {
    // Extract the first link and see if it's usable
    // Ensure that it really does come directly after #REDIRECT
    // Some older redirects included a colon, so don't freak about that!
    $m = array();
    if ( preg_match( '!^\s*:?\s*\[{2}(.*?)(?:\|.*?)?\]{2}!', $text, $m ) ) {
      // Strip preceding colon used to "escape" categories, etc.
      // and URL-decode links
      if ( strpos( $m[1], '%' ) !== false ) {
        // Match behavior of inline link parsing here;
        $m[1] = rawurldecode( ltrim( $m[1], ':' ) );
      }
      $title = Title::newFromText( $m[1] );
      // If the title is a redirect to bad special pages or is invalid, return
null
      if ( !$title instanceof Title || !$title->isValidRedirectTarget() ) {
        return null;
      }

      return $title;
    }
  }

  return null;
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to