MDL-85322 block_html: trust dashboard content in WS context

This commit is contained in:
Daniel Ureña
2026-03-03 11:55:06 +01:00
parent e5429f2831
commit df9a67b8a5
2 changed files with 21 additions and 3 deletions
@@ -0,0 +1,8 @@
issueNumber: MDL-85322
notes:
block_html:
- message: >-
Treat Dashboard (pagetype 'my-index') as trusted in web services so
get_content_for_external preserves embedded HTML (e.g. iframes) on user
Dashboard.
type: changed
+13 -3
View File
@@ -165,14 +165,24 @@ class block_html extends block_base {
}
function content_is_trusted() {
global $SCRIPT;
global $SCRIPT, $USER;
if (!$context = context::instance_by_id($this->instance->parentcontextid, IGNORE_MISSING)) {
return false;
}
//find out if this block is on the profile page
if ($context->contextlevel == CONTEXT_USER) {
if ($SCRIPT === '/my/index.php') {
$usersubpage = my_get_page($USER->id);
$usersubpage = $usersubpage->id ?? null;
if (
$SCRIPT === '/my/index.php' ||
(
defined('WS_SERVER') &&
WS_SERVER &&
!empty($this->page) &&
$this->page->pagetype === 'my-index' &&
$this->page->subpage === $usersubpage
)
) {
// this is exception - page is completely private, nobody else may see content there
// that is why we allow JS here
return true;