diff --git a/build/psalm-baseline-ocp.xml b/build/psalm-baseline-ocp.xml
index ce406cfde750c..ed932f8d48725 100644
--- a/build/psalm-baseline-ocp.xml
+++ b/build/psalm-baseline-ocp.xml
@@ -53,17 +53,6 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/lib/private/Template/Base.php b/lib/private/Template/Base.php
index 0dd7d92d6be1a..a13e67039602a 100644
--- a/lib/private/Template/Base.php
+++ b/lib/private/Template/Base.php
@@ -136,6 +136,7 @@ protected function load(string $file, ?array $additionalParams = null): string {
// Include
ob_start();
try {
+ require_once __DIR__ . '/functions.php';
include $file;
$data = ob_get_contents();
} catch (\Exception $e) {
diff --git a/lib/private/Template/Template.php b/lib/private/Template/Template.php
index b69d68b944fa0..ee85562091f81 100644
--- a/lib/private/Template/Template.php
+++ b/lib/private/Template/Template.php
@@ -21,8 +21,6 @@
use OCP\Template\TemplateNotFoundException;
use OCP\Util;
-require_once __DIR__ . '/../legacy/template/functions.php';
-
class Template extends Base implements ITemplate {
private string $path;
private array $headers = [];
diff --git a/lib/private/legacy/template/functions.php b/lib/private/Template/functions.php
similarity index 75%
rename from lib/private/legacy/template/functions.php
rename to lib/private/Template/functions.php
index 37df801c3c4ed..4354d0d8fce9d 100644
--- a/lib/private/legacy/template/functions.php
+++ b/lib/private/Template/functions.php
@@ -6,20 +6,23 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
+use OC\Security\CSP\ContentSecurityPolicyNonceManager;
+use OCP\Files\IMimeTypeDetector;
use OCP\IDateTimeFormatter;
+use OCP\IURLGenerator;
+use OCP\Server;
use OCP\Util;
-function p($string) {
- print(\OCP\Util::sanitizeHTML($string));
+function p(string $string): void {
+ print(Util::sanitizeHTML($string));
}
-
/**
* Prints a tag for loading css
* @param string $href the source URL, ignored when empty
* @param string $opts, additional optional options
*/
-function emit_css_tag($href, $opts = '') {
+function emit_css_tag($href, $opts = ''): void {
$s = 'get(\OC\Security\CSP\ContentSecurityPolicyNonceManager::class);
+function emit_script_tag(string $src, string $script_content = '', string $content_type = ''): void {
+ $nonceManager = Server::get(ContentSecurityPolicyNonceManager::class);
$defer_str = ' defer';
$type = $content_type !== '' ? ' type="' . $content_type . '"' : '';
@@ -74,7 +77,7 @@ function emit_script_tag(string $src, string $script_content = '', string $conte
* Print all