Plugin Directory

Changeset 3415496


Ignore:
Timestamp:
12/09/2025 02:07:58 PM (5 days ago)
Author:
bastho
Message:

Sanitize values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • eelv-redirection/trunk/eelv_redirection.php

    r3415486 r3415496  
    2929        return false;
    3030    }
    31     if(defined('REDIRECT_ALLOW_USER_AGENT') && strstr($_SERVER['HTTP_USER_AGENT'], REDIRECT_ALLOW_USER_AGENT)){
     31    if(defined('REDIRECT_ALLOW_USER_AGENT') && isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], REDIRECT_ALLOW_USER_AGENT)){
    3232        @header("X-Redirect-Debug: Allowed by user-agent pattern", true);
    3333        return false;
    3434    }
    35     return ($dir!='wp-admin' && $dir!='network' && !preg_match('#^/wp-(.*).php#', $_SERVER['SCRIPT_NAME']));
     35    return ($dir!='wp-admin' && $dir!='network' && isset($_SERVER['SCRIPT_NAME']) && !preg_match('#^/wp-(.*).php#', $_SERVER['SCRIPT_NAME']));
    3636}
    3737
    3838function get_redirect_url(){
    3939    $redirect_url = get_option('eelv_url_redirect');
    40     if(strstr($redirect_url, '%query_string%')){
    41         $redirect_url =str_replace('%query_string%', $_SERVER['QUERY_STRING'], $redirect_url);
     40    if(strstr($redirect_url, '%query_string%') && isset($_SERVER['QUERY_STRING'])){
     41        $redirect_url =str_replace('%query_string%', sanitize_text_field($_SERVER['QUERY_STRING']), $redirect_url);
    4242    }
    43     if(strstr($redirect_url, '%request_uri%')){
    44         $redirect_url =str_replace('%request_uri%', $_SERVER['REQUEST_URI'], $redirect_url);
     43    if(strstr($redirect_url, '%request_uri%') && isset($_SERVER['REQUEST_URI'])){
     44        $redirect_url =str_replace('%request_uri%', sanitize_text_field($_SERVER['REQUEST_URI']), $redirect_url);
    4545    }
    4646    return $redirect_url;
     
    9090    // If they did, this hidden field will be set to 'Y'
    9191    if( isset($_POST[ 'eelv_url_redirect' ])) {
    92         if (wp_verify_nonce( $_REQUEST['_wpnonce'], 'eelv_redirection_settings')){ 
     92        if (wp_verify_nonce( sanitize_text_field($_REQUEST['_wpnonce']), 'eelv_redirection_settings')){ 
    9393            update_option( 'eelv_url_redirect', esc_url_raw(filter_input(INPUT_POST, 'eelv_url_redirect', FILTER_SANITIZE_URL)));
    94             update_option( "eelv_code_redirect", sanitize_text_field($_POST[ 'eelv_code_redirect' ]));
    95             update_option( "eelv_when_redirect", sanitize_text_field($_POST[ 'eelv_when_redirect' ]));
     94            update_option( "eelv_code_redirect", sanitize_text_field($_POST[ 'eelv_code_redirect' ] ?? ''));
     95            update_option( "eelv_when_redirect", sanitize_text_field($_POST[ 'eelv_when_redirect' ] ?? ''));
    9696            ?>
    97             <div class="updated"><p><strong><?php echo esc_html(__('Option saved','eelv-redirection'))?></strong></p></div>
     97            <div class="updated"><p><strong><?php esc_html_e('Option saved','eelv-redirection'); ?></strong></p></div>
    9898            <?php
    9999        }else{
    100100            ?>   
    101             <div class="error"><p><strong><?php echo esc_html(__('Warning there has been a hacking attempt','eelv-redirection'))?></strong></p></div>
     101            <div class="error"><p><strong><?php esc_html_e('Warning there has been a hacking attempt','eelv-redirection'); ?></strong></p></div>
    102102            <?php
    103103        }
Note: See TracChangeset for help on using the changeset viewer.