MDL-79276 core: Fix html validation with streaming api

This commit is contained in:
Brendan Heywood
2023-10-02 21:11:44 +10:00
parent 10dd816af1
commit 79c2e4bdae
2 changed files with 19 additions and 0 deletions
+5
View File
@@ -244,5 +244,10 @@ class core_shutdown_manager {
}
}
}
// Print any closing buffered tags.
if (!empty($CFG->closingtags)) {
echo $CFG->closingtags;
}
}
}
+14
View File
@@ -1549,6 +1549,20 @@ class core_renderer extends renderer_base {
$this->page->set_state(moodle_page::STATE_DONE);
// Here we remove the closing body and html tags and store them to be added back
// in the shutdown handler so we can have valid html with streaming script tags
// which are rendered after the visible footer.
$tags = '';
preg_match('#\<\/body>#i', $footer, $matches);
$tags .= $matches[0];
$footer = str_replace($matches[0], '', $footer);
preg_match('#\<\/html>#i', $footer, $matches);
$tags .= $matches[0];
$footer = str_replace($matches[0], '', $footer);
$CFG->closingtags = $tags;
return $output . $footer;
}