Skip to content

Commit e023a4f

Browse files
committed
fix: improve rejected pages config handling and nonce verification
1 parent a67014c commit e023a4f

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

wp-cache.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,17 +1718,17 @@ function wpsc_edit_rejected_ua() {
17181718
}
17191719

17201720
function wp_cache_update_rejected_pages() {
1721-
global $wp_cache_config_file, $valid_nonce, $wp_cache_pages;
1721+
global $wp_cache_config_file, $wp_cache_pages;
17221722

1723-
if ( isset( $_POST[ 'wp_edit_rejected_pages' ] ) && $valid_nonce ) {
1723+
if ( isset( $_POST['wp_edit_rejected_pages'], $_POST['_wpnonce'] )
1724+
&& wp_verify_nonce( $_POST['_wpnonce'], 'wp-cache' )
1725+
) {
17241726
$pages = array( 'single', 'pages', 'archives', 'tag', 'frontpage', 'home', 'category', 'feed', 'author', 'search' );
1725-
foreach( $pages as $page ) {
1726-
if ( isset( $_POST[ 'wp_cache_pages' ][ $page ] ) ) {
1727-
$value = 1;
1728-
} else {
1729-
$value = 0;
1730-
}
1731-
wp_cache_replace_line('^ *\$wp_cache_pages\[ "' . $page . '" \]', "\$wp_cache_pages[ \"{$page}\" ] = $value;", $wp_cache_config_file);
1727+
foreach ( $pages as $page ) {
1728+
$value = empty( $_POST['wp_cache_pages'][ $page ] ) ? 0 : 1;
1729+
1730+
$page_regexp = '\s*(' . preg_quote( "'" . $page . "'" ) . '|' . preg_quote( '"' . $page . '"' ) . ')\s*';
1731+
wp_cache_replace_line( '^\s*\$wp_cache_pages\[' . $page_regexp . '\]', "\$wp_cache_pages[ \"{$page}\" ] = $value;", $wp_cache_config_file );
17321732
$wp_cache_pages[ $page ] = $value;
17331733
}
17341734
}

0 commit comments

Comments
 (0)