From: Alexandre Emsenhuber Date: Mon, 14 Jan 2013 21:09:26 +0000 (+0100) Subject: (bug 43964) Invalid value of "link" parameter in no longer produces a fatal... X-Git-Tag: 1.31.0-rc.0~20929^2 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=6f74a93d1bfdafeeb2b3b80fc022cdb5e369827c;p=lhc%2Fweb%2Fwiklou.git (bug 43964) Invalid value of "link" parameter in no longer produces a fatal error Also added a test for this just in case someone wants to break this :) Change-Id: I2782cf1a45b574eb5fd69b1c1be561e7bdaef59e --- diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21 index 01ff993d55..a2949a0b76 100644 --- a/RELEASE-NOTES-1.21 +++ b/RELEASE-NOTES-1.21 @@ -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 === @@ -152,6 +152,8 @@ production. * 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 no longer produces + a fatal error. === API changes in 1.21 === * prop=revisions can now report the contentmodel and contentformat. diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index d47ccb9592..478bd6d988 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -4988,13 +4988,17 @@ class Parser { $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 { diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 63c9e653a2..8a9791be6b 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -12675,6 +12675,23 @@ File:foobar.jpg|caption|alt=galleryalt|link=" onclick="alert('malicious javascri !! end +!!test +Gallery with invalid title as link (bug 43964) +!! input + +File:foobar.jpg|link=< + +!! result + + +!! end + !!test Language parser function !! input