From 64b6651cfa2a8d6086f7edb76d7749c2bf9b8e55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Fri, 16 Jun 2017 13:36:32 +0200 Subject: [PATCH] MDL-59269 lang: Fix ability to uninstall certain language packs In the issue MDL-39319 (6ddf92c77), the ability to uninstall multiple language packs at once was added. By a mistake, the PARAM_ALPHAEXT was used as paramater type for the dash-separated list of language packs to be uninstalled. Language packs with a number in the name (such as en_us_k12) do not pass the ALPHAEXT cleaning. This patch changes the parameter cleaning to PARAM_SAFEPATH which is more appropriate for the given scenario as language code themselves must be SAFEDIRs. --- admin/tool/langimport/index.php | 10 ++++++---- .../moodle-core-languninstallconfirm-debug.js | 2 +- .../moodle-core-languninstallconfirm-min.js | 2 +- .../moodle-core-languninstallconfirm.js | 2 +- .../languninstallconfirm/js/languninstallconfirm.js | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/admin/tool/langimport/index.php b/admin/tool/langimport/index.php index 0e98a5d2de4..92a09dad241 100644 --- a/admin/tool/langimport/index.php +++ b/admin/tool/langimport/index.php @@ -40,7 +40,7 @@ if (empty($CFG->langotherroot)) { $mode = optional_param('mode', 0, PARAM_INT); // action $pack = optional_param_array('pack', array(), PARAM_SAFEDIR); // pack to install $uninstalllang = optional_param_array('uninstalllang', array(), PARAM_LANG);// installed pack to uninstall -$confirmtounistall = optional_param('confirmtouninstall', '', PARAM_ALPHAEXT); // uninstallation confirmation +$confirmtounistall = optional_param('confirmtouninstall', '', PARAM_SAFEPATH); // uninstallation confirmation $purgecaches = optional_param('purgecaches', false, PARAM_BOOL); // explicit caches reset if ($purgecaches) { @@ -74,7 +74,7 @@ if ($mode == DELETION_OF_SELECTED_LANG and (!empty($uninstalllang) or !empty($co // Actually deleting languages, languages to delete are passed as GET parameter as string // ...need to populate them to array. if (empty($uninstalllang)) { - $uninstalllang = explode('-', $confirmtounistall); + $uninstalllang = explode('/', $confirmtounistall); } if (in_array('en', $uninstalllang)) { @@ -84,8 +84,10 @@ if ($mode == DELETION_OF_SELECTED_LANG and (!empty($uninstalllang) or !empty($co } else if (empty($confirmtounistall) and confirm_sesskey()) { // User chose langs to be deleted, show confirmation. echo $OUTPUT->header(); echo $OUTPUT->confirm(get_string('uninstallconfirm', 'tool_langimport', implode(', ', $uninstalllang)), - 'index.php?mode='.DELETION_OF_SELECTED_LANG.'&confirmtouninstall='.implode('-', $uninstalllang), - 'index.php'); + new moodle_url($PAGE->url, array( + 'mode' => DELETION_OF_SELECTED_LANG, + 'confirmtouninstall' => implode('/', $uninstalllang), + )), $PAGE->url); echo $OUTPUT->footer(); die; diff --git a/lib/yui/build/moodle-core-languninstallconfirm/moodle-core-languninstallconfirm-debug.js b/lib/yui/build/moodle-core-languninstallconfirm/moodle-core-languninstallconfirm-debug.js index d12bfd2320e..6f50f4c2c34 100644 --- a/lib/yui/build/moodle-core-languninstallconfirm/moodle-core-languninstallconfirm-debug.js +++ b/lib/yui/build/moodle-core-languninstallconfirm/moodle-core-languninstallconfirm-debug.js @@ -98,7 +98,7 @@ Y.extend(Confirmation, Y.Base, { _uninstall: function(e, langCodes) { Y.config.win.location.href = this.get('uninstallUrl') + '?mode=4' + '&sesskey=' + M.cfg.sesskey + - '&confirmtouninstall=' + langCodes.join('-'); + '&confirmtouninstall=' + langCodes.join('/'); } }); diff --git a/lib/yui/build/moodle-core-languninstallconfirm/moodle-core-languninstallconfirm-min.js b/lib/yui/build/moodle-core-languninstallconfirm/moodle-core-languninstallconfirm-min.js index fd52350bcd1..94a7844dd2a 100644 --- a/lib/yui/build/moodle-core-languninstallconfirm/moodle-core-languninstallconfirm-min.js +++ b/lib/yui/build/moodle-core-languninstallconfirm/moodle-core-languninstallconfirm-min.js @@ -1 +1 @@ -YUI.add("moodle-core-languninstallconfirm",function(e,t){function n(){n.superclass.constructor.apply(this,arguments)}var r={UNINSTALLBUTTON:"#languninstallbutton",UNINSTALLSELECT:"#menuuninstalllang option",ENGLISHOPTION:"#menuuninstalllang option[value='en']"};n.NAME=t,n.ATTRS={uninstallUrl:{validator:e.Lang.isString}},e.extend(n,e.Base,{initializer:function(){e.one(r.UNINSTALLBUTTON).on("click",this._confirm,this)},_confirm:function(t){t.preventDefault();var n=[],i=[];e.all(r.UNINSTALLSELECT).each(function(e){e.get("selected")&&(n.push(e.getAttribute("value")),i.push(e.get("text")))});if(n.length===0){(new M.core.alert({message:M.util.get_string("selectlangs","tool_langimport")})).show();return}if(n.indexOf("en")>-1){e.one(r.ENGLISHOPTION).set("selected",!1),(new M.core.alert({message:M.util.get_string("noenglishuninstall","tool_langimport")})).show();return}var s={modal:!0,visible:!1,centered:!0,title:M.util.get_string("uninstall","tool_langimport"),question:M.util.get_string("uninstallconfirm","tool_langimport",i.join(", "))};(new M.core.confirm(s)).show().on("complete-yes",this._uninstall,this,n)},_uninstall:function(t,n){e.config.win.location.href=this.get("uninstallUrl")+"?mode=4"+"&sesskey="+M.cfg.sesskey+"&confirmtouninstall="+n.join("-")}}),e.namespace("M.core.languninstallconfirm").Confirmation=n,e.namespace("M.core.languninstallconfirm").init=function(e){return new n(e)}},"@VERSION@",{requires:["base","node","moodle-core-notification-confirm","moodle-core-notification-alert"]}); +YUI.add("moodle-core-languninstallconfirm",function(e,t){function n(){n.superclass.constructor.apply(this,arguments)}var r={UNINSTALLBUTTON:"#languninstallbutton",UNINSTALLSELECT:"#menuuninstalllang option",ENGLISHOPTION:"#menuuninstalllang option[value='en']"};n.NAME=t,n.ATTRS={uninstallUrl:{validator:e.Lang.isString}},e.extend(n,e.Base,{initializer:function(){e.one(r.UNINSTALLBUTTON).on("click",this._confirm,this)},_confirm:function(t){t.preventDefault();var n=[],i=[];e.all(r.UNINSTALLSELECT).each(function(e){e.get("selected")&&(n.push(e.getAttribute("value")),i.push(e.get("text")))});if(n.length===0){(new M.core.alert({message:M.util.get_string("selectlangs","tool_langimport")})).show();return}if(n.indexOf("en")>-1){e.one(r.ENGLISHOPTION).set("selected",!1),(new M.core.alert({message:M.util.get_string("noenglishuninstall","tool_langimport")})).show();return}var s={modal:!0,visible:!1,centered:!0,title:M.util.get_string("uninstall","tool_langimport"),question:M.util.get_string("uninstallconfirm","tool_langimport",i.join(", "))};(new M.core.confirm(s)).show().on("complete-yes",this._uninstall,this,n)},_uninstall:function(t,n){e.config.win.location.href=this.get("uninstallUrl")+"?mode=4"+"&sesskey="+M.cfg.sesskey+"&confirmtouninstall="+n.join("/")}}),e.namespace("M.core.languninstallconfirm").Confirmation=n,e.namespace("M.core.languninstallconfirm").init=function(e){return new n(e)}},"@VERSION@",{requires:["base","node","moodle-core-notification-confirm","moodle-core-notification-alert"]}); diff --git a/lib/yui/build/moodle-core-languninstallconfirm/moodle-core-languninstallconfirm.js b/lib/yui/build/moodle-core-languninstallconfirm/moodle-core-languninstallconfirm.js index d12bfd2320e..6f50f4c2c34 100644 --- a/lib/yui/build/moodle-core-languninstallconfirm/moodle-core-languninstallconfirm.js +++ b/lib/yui/build/moodle-core-languninstallconfirm/moodle-core-languninstallconfirm.js @@ -98,7 +98,7 @@ Y.extend(Confirmation, Y.Base, { _uninstall: function(e, langCodes) { Y.config.win.location.href = this.get('uninstallUrl') + '?mode=4' + '&sesskey=' + M.cfg.sesskey + - '&confirmtouninstall=' + langCodes.join('-'); + '&confirmtouninstall=' + langCodes.join('/'); } }); diff --git a/lib/yui/src/languninstallconfirm/js/languninstallconfirm.js b/lib/yui/src/languninstallconfirm/js/languninstallconfirm.js index 88eead86e08..98d87ea2019 100644 --- a/lib/yui/src/languninstallconfirm/js/languninstallconfirm.js +++ b/lib/yui/src/languninstallconfirm/js/languninstallconfirm.js @@ -96,7 +96,7 @@ Y.extend(Confirmation, Y.Base, { _uninstall: function(e, langCodes) { Y.config.win.location.href = this.get('uninstallUrl') + '?mode=4' + '&sesskey=' + M.cfg.sesskey + - '&confirmtouninstall=' + langCodes.join('-'); + '&confirmtouninstall=' + langCodes.join('/'); } });