jenkins-bot has submitted this change and it was merged.

Change subject: Never allow unsupported source or target languages in the page 
selector
......................................................................


Never allow unsupported source or target languages in the page selector

Bug: T132217
Change-Id: If4d16eca493c0c8a2b125769436d22b942757f01
---
M modules/source/ext.cx.source.selector.js
1 file changed, 11 insertions(+), 2 deletions(-)

Approvals:
  Santhosh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/source/ext.cx.source.selector.js 
b/modules/source/ext.cx.source.selector.js
index 6357bf0..ff4593a 100644
--- a/modules/source/ext.cx.source.selector.js
+++ b/modules/source/ext.cx.source.selector.js
@@ -179,6 +179,11 @@
        CXSourceSelector.prototype.setSourceLanguage = function ( language ) {
                var langProps, currentSource;
 
+               // Do not allow selection of invalid source languages under any 
circumstances
+               if ( !this.isValidSource( language ) ) {
+                       return;
+               }
+
                // Don't let the same languages be selected as source and 
target.
                // Instead, do what the user probably means: either swap them if
                // it's valid, or pick the first of the common languages in ULS.
@@ -226,6 +231,10 @@
                        lang: language,
                        dir: $.uls.data.getDir( language )
                };
+
+               if ( !this.isValidTarget( language ) ) {
+                       return;
+               }
 
                this.$targetTitleInput.prop( langProps );
                this.$targetLanguage.prop( langProps )
@@ -700,7 +709,7 @@
                targetLanguage = storedTargetLanguage || mw.config.get( 
'wgContentLanguage' );
                sourceLanguage = storedSourceLanguage;
 
-               if ( !sourceLanguage ) {
+               if ( !this.isValidSource( sourceLanguage ) ) {
                        commonSourceLanguages = this.$sourceLanguage.data( 
'uls' ).options.quickList();
 
                        for ( i = 0; i < commonSourceLanguages.length; i++ ) {
@@ -715,7 +724,7 @@
                }
 
                // Still couldn't find a valid source language?
-               if ( !sourceLanguage ) {
+               if ( !this.isValidSource( sourceLanguage ) ) {
                        sourceLanguage = mw.config.get( 
'wgContentTranslationDefaultSourceLanguage' );
                }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/290667
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If4d16eca493c0c8a2b125769436d22b942757f01
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <niklas.laxst...@gmail.com>
Gerrit-Reviewer: Amire80 <amir.ahar...@mail.huji.ac.il>
Gerrit-Reviewer: Santhosh <santhosh.thottin...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to