Merge branch 'MDL-79577-402' of https://github.com/paulholden/moodle into MOODLE_402_STABLE

This commit is contained in:
Sara Arjona
2024-02-08 16:11:36 +08:00
committed by Andrew Nicols
2 changed files with 3 additions and 7 deletions
+1
View File
@@ -41,6 +41,7 @@ class user_menu_test extends \advanced_testcase {
array('_____', 0, 0),
array('test', 0, 0),
array('#Garbage#', 0, 0),
array('privatefiles,/user/files.php', 0, 0),
// These are valid but have an invalid string identifiers or components. They will still produce a menu
// item, and no exception should be thrown.
+2 -7
View File
@@ -708,13 +708,7 @@ function user_count_login_failures($user, $reset = true) {
* @return array
*/
function user_convert_text_to_menu_items($text, $page) {
global $OUTPUT, $CFG;
$lines = explode("\n", $text);
$items = array();
$lastchild = null;
$lastdepth = null;
$lastsort = 0;
$children = array();
foreach ($lines as $line) {
$line = trim($line);
@@ -742,8 +736,9 @@ function user_convert_text_to_menu_items($text, $page) {
// Name processing.
$namebits = explode(',', $bits[0], 2);
if (count($namebits) == 2) {
$namebits[1] = $namebits[1] ?: 'core';
// Check the validity of the identifier part of the string.
if (clean_param($namebits[0], PARAM_STRINGID) !== '') {
if (clean_param($namebits[0], PARAM_STRINGID) !== '' && clean_param($namebits[1], PARAM_COMPONENT) !== '') {
// Treat this as a language string.
$child->title = get_string($namebits[0], $namebits[1]);
$child->titleidentifier = implode(',', $namebits);