X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialSearch.php;h=26b86f9762cf75173023058b6374f8e3a4803dcd;hb=c2e8264b5349d3efed998b4f53abe0c289ec3b18;hp=45d24152bee6b72d1de9ee01fde91fdfb20fbdb5;hpb=b2842997aae4a28dd330885f82a6ac2f8af7834d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 45d24152be..26b86f9762 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -100,6 +100,25 @@ class SpecialSearch extends SpecialPage { * @param string $par */ public function execute( $par ) { + $request = $this->getRequest(); + + // Fetch the search term + $search = str_replace( "\n", " ", $request->getText( 'search' ) ); + + // Historically search terms have been accepted not only in the search query + // parameter, but also as part of the primary url. This can have PII implications + // in releasing page view data. As such issue a 301 redirect to the correct + // URL. + if ( strlen( $par ) && !strlen( $search ) ) { + $query = $request->getValues(); + unset( $query['title'] ); + // Strip underscores from title parameter; most of the time we'll want + // text form here. But don't strip underscores from actual text params! + $query['search'] = str_replace( '_', ' ', $par ); + $this->getOutput()->redirect( $this->getPageTitle()->getFullURL( $query ), 301 ); + return; + } + $this->setHeaders(); $this->outputHeader(); $out = $this->getOutput(); @@ -110,15 +129,6 @@ class SpecialSearch extends SpecialPage { ] ); $this->addHelpLink( 'Help:Searching' ); - // Strip underscores from title parameter; most of the time we'll want - // text form here. But don't strip underscores from actual text params! - $titleParam = str_replace( '_', ' ', $par ); - - $request = $this->getRequest(); - - // Fetch the search term - $search = str_replace( "\n", " ", $request->getText( 'search', $titleParam ) ); - $this->load(); if ( !is_null( $request->getVal( 'nsRemember' ) ) ) { $this->saveNamespaces(); @@ -386,7 +396,7 @@ class SpecialSearch extends SpecialPage { if ( $textMatches && !$textStatus ) { // output appropriate heading if ( $numTextMatches > 0 && $numTitleMatches > 0 ) { - $out->addHTML( '
' ); + $out->addHTML( '
' ); // if no title matches the heading is redundant $out->wrapWikiMsg( "==$1==\n", 'textmatches' ); } @@ -435,7 +445,7 @@ class SpecialSearch extends SpecialPage { $textMatches->free(); } - $out->addHTML( '
' ); + $out->addHTML( '
' ); if ( $prevnext ) { $out->addHTML( "

{$prevnext}

\n" ); @@ -456,7 +466,7 @@ class SpecialSearch extends SpecialPage { protected function interwikiHeader( $interwiki, $interwikiResult ) { // TODO: we need to figure out how to name wikis correctly $wikiMsg = $this->msg( 'search-interwiki-results-' . $interwiki )->parse(); - return "

\n$wikiMsg

"; + return "

\n$wikiMsg

"; } /** @@ -720,7 +730,7 @@ class SpecialSearch extends SpecialPage { $out .= "\n"; @@ -1166,7 +1176,7 @@ class SpecialSearch extends SpecialPage { * @return string */ protected function searchProfileTabs( $term ) { - $out = Html::element( 'div', [ 'class' => 'visualClear' ] ) . + $out = Html::element( 'div', [ 'class' => 'mw-search-visualclear' ] ) . Xml::openElement( 'div', [ 'class' => 'mw-search-profile-tabs' ] ); $bareterm = $term; @@ -1244,6 +1254,7 @@ class SpecialSearch extends SpecialPage { 'autofocus' => trim( $term ) === '', 'value' => $term, 'dataLocation' => 'content', + 'infusable' => true, ] ); $layout = new OOUI\ActionFieldLayout( $searchWidget, new OOUI\ButtonInputWidget( [