Skip to content

Commit 60bd350

Browse files
authored
Restrict supercache filename to a safe character set (#1050)
Ensure the generated supercache filename is always a single, well-formed path segment regardless of what filters return.
1 parent d066a0d commit 60bd350

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

wp-cache-phase2.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,11 @@ function supercache_filename() {
10891089
if ( is_array( $cached_direct_pages ) && in_array( $_SERVER['REQUEST_URI'], $cached_direct_pages ) ) {
10901090
$extra_str = '';
10911091
}
1092+
1093+
// The filename must always be a single path segment. Filters above may
1094+
// return arbitrary data, so restrict it to a safe set of characters.
1095+
$extra_str = preg_replace( '/[^a-zA-Z0-9_-]/', '', (string) $extra_str );
1096+
10921097
$filename = 'index' . $extra_str . '.html';
10931098

10941099
return $filename;

0 commit comments

Comments
 (0)