From 13fe0f561245536be6ce440d5d62316150cc9f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 11 Mar 2025 11:31:59 +0100 Subject: [PATCH] fix: Clean up typing and remove deprecated calls in template functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/private/Template/functions.php | 62 +++++++++++++++++------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/lib/private/Template/functions.php b/lib/private/Template/functions.php index 37df801c3c4..d9cf5f3f63a 100644 --- a/lib/private/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