From 4be66b0dfb09eb9c4119d789a19e565307f60d2f Mon Sep 17 00:00:00 2001 From: Diego Monroy Date: Wed, 3 Sep 2025 21:50:34 +0200 Subject: [PATCH] MDL-86541 blocks: validate allowing block title to be '0' (zero). --- public/lib/classes/output/core_renderer.php | 3 ++- public/lib/templates/block.mustache | 22 +++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/public/lib/classes/output/core_renderer.php b/public/lib/classes/output/core_renderer.php index d4b87f91953..40dad670724 100644 --- a/public/lib/classes/output/core_renderer.php +++ b/public/lib/classes/output/core_renderer.php @@ -1495,7 +1495,8 @@ class core_renderer extends renderer_base { $context->ariarole = !empty($bc->attributes['role']) ? $bc->attributes['role'] : ''; $context->class = $bc->attributes['class']; $context->type = $bc->attributes['data-block']; - $context->title = $bc->title; + $context->title = (string) $bc->title; + $context->showtitle = $context->title !== ''; $context->content = $bc->content; $context->annotation = $bc->annotation; $context->footer = $bc->footer; diff --git a/public/lib/templates/block.mustache b/public/lib/templates/block.mustache index 9857ad8906e..840ef29a969 100644 --- a/public/lib/templates/block.mustache +++ b/public/lib/templates/block.mustache @@ -1,3 +1,16 @@ +{{! + This file is part of Moodle - http://moodle.org/ + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} {{! @template core/block @@ -8,6 +21,7 @@ "showskiplink": true, "type": "html", "ariarole": "", + "showtitle": true, "title": "Test block", "blockinstanceid": 1, "content": "

Hello block world!

" @@ -29,18 +43,18 @@ aria-label="{{arialabel}}" {{/arialabel}} {{^arialabel}} - {{#title}} + {{#showtitle}} aria-labelledby="instance-{{blockinstanceid}}-header" - {{/title}} + {{/showtitle}} {{/arialabel}}> {{! Block contents }}
{{! Block header }} - {{#title}} + {{#showtitle}}

{{{title}}}

- {{/title}} + {{/showtitle}} {{#hascontrols}}