From 7310d70b932f524364fa1542b425b7fc050df511 Mon Sep 17 00:00:00 2001 From: Terranom674 Date: Thu, 3 Sep 2026 14:41:44 +0200 Subject: [PATCH] Add strict WebDAV derivative cache validation --- include/webdav_cache_validation.inc.php | 66 +++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 include/webdav_cache_validation.inc.php diff --git a/include/webdav_cache_validation.inc.php b/include/webdav_cache_validation.inc.php new file mode 100644 index 0000000..f5400e8 --- /dev/null +++ b/include/webdav_cache_validation.inc.php @@ -0,0 +1,66 @@ +get_size(); + $expected_width = (int)($expected[0] ?? 0); + $expected_height = (int)($expected[1] ?? 0); + if ($expected_width > 0 && $expected_height > 0) + { + if ((int)$actual[0] !== $expected_width || (int)$actual[1] !== $expected_height) + { + $reason = 'dimension-mismatch:'.(int)$actual[0].'x'.(int)$actual[1].'!='.$expected_width.'x'.$expected_height; + return false; + } + } + } + + if (is_object($params) && isset($params->last_mod_time)) + { + $mtime = @filemtime($target_path); + if ($mtime === false || (int)$mtime < (int)$params->last_mod_time) + { + $reason = 'stale-params'; + return false; + } + } + + $reason = 'valid'; + return true; +}