Merge "(bug 43964) Invalid value of "link" parameter in <gallery> no longer produces...
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 24 Jan 2013 19:32:59 +0000 (19:32 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 24 Jan 2013 19:32:59 +0000 (19:32 +0000)
1  2 
RELEASE-NOTES-1.21
includes/parser/Parser.php

diff --combined RELEASE-NOTES-1.21
@@@ -83,7 -83,7 +83,7 @@@ production
    in MW 1.20 (saving preferences using Special:Preferences cleared any
    additional fields) and which has been disabled in 1.20.1 as a part of
    a security fix (bug 42202).
- * Added the ability to limit the wall clock time used by shell processes, 
+ * Added the ability to limit the wall clock time used by shell processes,
    as well as the CPU time. Configurable with $wgMaxShellWallClockTime.
  
  === Bug fixes in 1.21 ===
  * wfMerge() now works if $wgDiff3 contains spaces
  * (bug 43052) mediawiki.action.view.dblClickEdit.dblClickEdit should trigger
    ca-edit click instead opening URL directly.
+ * (bug 43964) Invalid value of "link" parameter in <gallery> no longer produces
+   a fatal error.
  
  === API changes in 1.21 ===
  * prop=revisions can now report the contentmodel and contentformat.
    a redirect and its target.
  * (bug 43849) ApiQueryImageInfo no longer throws exceptions with ForeignDBRepo
    redirects.
 +* On error, any warnings generated before that error will be shown in the result.
  
  === API internal changes in 1.21 ===
  * For debugging only, a new global $wgDebugAPI removes many API restrictions when true.
@@@ -4492,14 -4492,14 +4492,14 @@@ class Parser 
                        '~~~' => $sigText
                ) );
  
 -              # Context links ("pipe trick"): [[|name]] and [[name (context)|]]
 +              # Context links ("pipe tricks"): [[|name]] and [[name (context)|]]
                $tc = '[' . Title::legalChars() . ']';
                $nc = '[ _0-9A-Za-z\x80-\xff-]'; # Namespaces can use non-ascii!
  
 -              $p1 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\))\\|]]/";                  # [[ns:page (context)|]]
 -              $p4 = "/\[\[(:?$nc+:|:|)($tc+?)( ?($tc+))\\|]]/";                    # [[ns:page(context)|]] (double-width brackets, added in r40257)
 -              $p3 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\)|)((?:, |,)$tc+|)\\|]]/"; # [[ns:page (context), context|]]
 -              $p2 = "/\[\[\\|($tc+)]]/";                                             # [[|page]]
 +              $p1 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\))\\|]]/";                   # [[ns:page (context)|]]
 +              $p4 = "/\[\[(:?$nc+:|:|)($tc+?)( ?($tc+))\\|]]/";                           # [[ns:page(context)|]] (double-width brackets, added in r40257)
 +              $p3 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\)|)((?:, |,)$tc+|)\\|]]/";         # [[ns:page (context), context|]] (using either single or double-width comma)
 +              $p2 = "/\[\[\\|($tc+)]]/";                                              # [[|page]] (reverse pipe trick: add context from page title)
  
                # try $p1 first, to turn "[[A, B (C)|]]" into "[[A, B (C)|A, B]]"
                $text = preg_replace( $p1, '[[\\1\\2\\3|\\2]]', $text );
                                                $alt = $this->stripAltText( $match, false );
                                        }
                                        elseif( $match = $magicWordLink->matchVariableStartToEnd( $parameterMatch ) ){
-                                               $link = strip_tags($this->replaceLinkHoldersText($match));
+                                               $linkValue = strip_tags( $this->replaceLinkHoldersText( $match ) );
                                                $chars = self::EXT_LINK_URL_CLASS;
                                                $prots = $this->mUrlProtocols;
                                                //check to see if link matches an absolute url, if not then it must be a wiki link.
-                                               if(!preg_match( "/^($prots)$chars+$/u", $link)){
-                                                       $localLinkTitle = Title::newFromText($link);
-                                                       $link = $localLinkTitle->getLocalURL();
+                                               if ( preg_match( "/^($prots)$chars+$/u", $linkValue ) ) {
+                                                       $link = $linkValue;
+                                               } else {
+                                                       $localLinkTitle = Title::newFromText( $linkValue );
+                                                       if ( $localLinkTitle !== null ) {
+                                                               $link = $localLinkTitle->getLocalURL();
+                                                       }
                                                }
                                        }
                                        else {