From 61b73348a17b147af9c26366f0cacca7c869e179 Mon Sep 17 00:00:00 2001 From: Benjamin Walker Date: Fri, 12 Apr 2024 17:09:53 +1000 Subject: [PATCH] Update group logic for pluginfiles #335 --- classes/script_metadata.php | 4 +++- tests/tool_excimer_script_metadata_test.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/classes/script_metadata.php b/classes/script_metadata.php index d6bf612..ff1d4a2 100644 --- a/classes/script_metadata.php +++ b/classes/script_metadata.php @@ -343,7 +343,7 @@ public static function get_groupby_value(profile $profile): string { } } $params = $profile->get('parameters'); - if ($params != '') { + if ($params != '' && !in_array($request, self::PLUGINFILE_SCRIPTS)) { $val .= '?' . self::redact_parameters($params); } if (empty($val)) { @@ -398,6 +398,8 @@ public static function redact_pathinfo(string $pathinfo): string { public static function redact_pluginfile_pathinfo(string $pathinfo): string { $segments = explode('/', ltrim($pathinfo, '/'), 4); $segments[0] = 'x'; + // Contextid for tokenpluginfile.php can be in $segments[1] depending on $CFG->slasharguments. + $segments[1] = ctype_digit($segments[1]) ? 'x' : $segments[1]; $segments[3] = 'xxx'; return '/' . implode('/', $segments); } diff --git a/tests/tool_excimer_script_metadata_test.php b/tests/tool_excimer_script_metadata_test.php index 6bb4385..b9af023 100644 --- a/tests/tool_excimer_script_metadata_test.php +++ b/tests/tool_excimer_script_metadata_test.php @@ -155,6 +155,7 @@ public function scriptgroup_value_provider(): array { ['admin/index.php', '', 'a=1&b&c=3', 'admin/index.php?a=&b&c='], ['admin/index.php', '/1/2/3/', 'a=1&b&c=3', 'admin/index.php/x/x/x/?a=&b&c='], ['pluginfile.php', '/12/mod/book/3242/3/tool.png', '', 'pluginfile.php/x/mod/book/xxx'], + ['tokenpluginfile.php', '/token/12/user/private/0/image.png', '', 'tokenpluginfile.php/x/x/user/xxx'], ]; }