Skip to content

Commit

Permalink
Ensure file cacher honours allow/disallow query string configs
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmitchell committed Nov 19, 2024
1 parent 400875b commit 0feac07
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/StaticCaching/Cachers/FileCacher.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function cachePage(Request $request, $content)
$content = $this->normalizeContent($content);

$path = $this->getFilePath($url);

if (! $this->writer->write($path, $content, $this->config('lock_hold_length'))) {
return;
}
Expand Down Expand Up @@ -301,6 +301,15 @@ public function getUrl(Request $request)

$qs = HeaderUtils::parseQuery($qs);

if ($allowedQueryStrings = $this->config('allowed_query_strings')) {
$qs = array_intersect_key($qs, array_flip($allowedQueryStrings));
}

if ($disallowedQueryStrings = $this->config('disallowed_query_strings')) {
$disallowedQueryStrings = array_flip($disallowedQueryStrings);
$qs = array_diff_key($qs, $disallowedQueryStrings);
}

return $url.'?'.http_build_query($qs, '', '&', \PHP_QUERY_RFC3986);
}
}

0 comments on commit 0feac07

Please sign in to comment.