From fcc5c4a96e9a19cea2e254be48b593fe7e6cc433 Mon Sep 17 00:00:00 2001 From: Paul Spenke Date: Mon, 23 Nov 2026 17:48:52 +0100 Subject: [PATCH] fix theme asset caching with file-based versioning Add cache-busting query string to phpb_theme_asset by appending the file's last-modified timestamp. Use realpath to resolve and validate the asset path before reading filemtime to prevent directory traversal. --- plugi-core/src/Core/helpers.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugi-core/src/Core/helpers.php b/plugi-core/src/Core/helpers.php index 98ba975..3b0d4b3 100644 --- a/plugi-core/src/Core/helpers.php +++ b/plugi-core/src/Core/helpers.php @@ -57,7 +57,10 @@ if (! function_exists('phpb_theme_asset')) { function phpb_theme_asset(string $path): string { $themeFolder = phpb_config('theme.folder_url') . '/' . phpb_config('theme.active_theme'); - return phpb_full_url($themeFolder . '/' . $path); + $themeRoot = __DIR__ . '/../../../themes/' . phpb_config('theme.active_theme'); + $assetPath = realpath($themeRoot . '/' . $path); + $version = ($assetPath && str_starts_with($assetPath, realpath($themeRoot))) ? filemtime($assetPath) : ''; + return phpb_full_url($themeFolder . '/' . $path) . '?v=' . $version; } }