Skip to content

Commit 9c72833

Browse files
committed
fix vulnerability in settings handling
1 parent f16812c commit 9c72833

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

admin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ function mfbfw_options_page() {
8585

8686
<form method="post" action="">
8787
<div style="text-align:center;padding:0 0 1.5em;margin:-15px 0 5px;">
88+
<?php wp_nonce_field( 'mfbfw-options-reset' ); ?>
8889
<input type="submit" name="mfbfw_update" id="reset" onClick="return confirmDefaults();" class="button-secondary" value="<?php esc_attr_e( 'Revert to defaults', 'mfbfw' ); ?>" />
8990
<input type="hidden" name="action" value="reset" />
9091
</div>

fancybox.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -366,21 +366,14 @@ function mfbfw_textdomain() {
366366

367367
function mfbfw_admin_options() {
368368

369-
if ( isset($_GET['page']) && $_GET['page'] == 'fancybox-for-wordpress' ) {
370-
371-
if ( isset($_REQUEST['action']) && 'update' == $_REQUEST['action'] ) {
372-
373-
$settings = stripslashes_deep( $_POST['mfbfw'] );
374-
$settings = array_map( 'convert_chars', $settings );
369+
$settings = get_option( 'mfbfw' );
375370

376-
update_option( 'mfbfw', $settings );
377-
wp_safe_redirect( add_query_arg('updated', 'true') );
378-
die;
371+
if ( isset($_GET['page']) && $_GET['page'] == 'fancybox-for-wordpress' ) {
379372

380-
} else if ( isset($_REQUEST['action']) && 'reset' == $_REQUEST['action'] ) {
373+
if ( isset($_REQUEST['action']) && 'reset' == $_REQUEST['action'] && check_admin_referer( 'mfbfw-options-reset' ) ) {
381374

382-
$default_settings = mfbfw_defaults(); // Store defaults in an array
383-
update_option( 'mfbfw', $default_settings ); // Write defaults to database
375+
$defaults_array = mfbfw_defaults(); // Store defaults in an array
376+
update_option( 'mfbfw', $defaults_array ); // Write defaults to database
384377
wp_safe_redirect( add_query_arg('reset', 'true') );
385378
die;
386379

0 commit comments

Comments
 (0)