From d173acb4643ea85d7d87efb36255f5b3ea6d15a7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Wed, 22 Jul 2015 02:16:20 +0200 Subject: [PATCH] mw.widgets.TitleInputWidget: Don't bypass namespace choice with redirects If 'namespace' was not null, and 'showRedirectTargets' was true (the default), pages from namespaces other than the chosen one could appear in the suggestions when a cross-namespace redirect from chosen to other namespace was encountered. Prevent this. Change-Id: Id863d002d598dc2429919e88dd2dde9e9836bb3d --- .../src/mediawiki.widgets/mw.widgets.TitleInputWidget.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js index a9e4384c50..66b009f3c5 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js @@ -201,7 +201,12 @@ imageUrl: OO.getProp( suggestionPage, 'thumbnail', 'source' ), description: OO.getProp( suggestionPage, 'terms', 'description' ) }; - titles.push( suggestionPage.title ); + + // Throw away pages from wrong namespaces. This can happen when 'showRedirectTargets' is true + // and we encounter a cross-namespace redirect. + if ( this.namespace === null || this.namespace === suggestionPage.ns ) { + titles.push( suggestionPage.title ); + } redirects = redirectsTo[suggestionPage.title] || []; for ( i = 0, len = redirects.length; i < len; i++ ) { -- 2.20.1