| @@ -31,10 +31,11 @@ | ||
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | + $redirect_to = ''; | |
| 35 | 36 | if ( isset( $_REQUEST['redirect_to'] ) ) { |
| 36 | - $redirect_to = esc_url_raw( $_REQUEST['redirect_to'] ); | |
| 37 | + $redirect_to = wppb_sanitize_request_url( $_REQUEST['redirect_to'] ); | |
| 37 | 38 | } |
| 38 | 39 | |
| 39 | 40 | $user = wp_signon( array(), $secure_cookie ); |
| 40 | 41 | |
| @@ -45,9 +46,9 @@ | ||
| 45 | 46 | 'https://codex.wordpress.org/Cookies', 'https://wordpress.org/support/' ) ); |
| 46 | 47 | } |
| 47 | 48 | } |
| 48 | 49 | |
| 49 | - $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? esc_url_raw( $_REQUEST['redirect_to'] ) : ''; | |
| 50 | + $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? wppb_sanitize_request_url( $_REQUEST['redirect_to'] ) : ''; | |
| 50 | 51 | /** |
| 51 | 52 | * Filters the login redirect URL. |
| 52 | 53 | */ |
| 53 | 54 | $redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user ); |
| @@ -165,11 +166,11 @@ | ||
| 165 | 166 | $form_location = 'widget'; |
| 166 | 167 | |
| 167 | 168 | // if an error is being shown pass the original referer forward |
| 168 | 169 | if( isset( $_GET['wppb_referer_url'] ) ){ |
| 169 | - $wppb_referer_url = esc_url_raw ( $_GET['wppb_referer_url'] ); | |
| 170 | + $wppb_referer_url = wppb_sanitize_request_url( $_GET['wppb_referer_url'] ); | |
| 170 | 171 | } else { |
| 171 | - $wppb_referer_url = esc_url_raw ( isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '' ); | |
| 172 | + $wppb_referer_url = wppb_sanitize_request_url( isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '' ); | |
| 172 | 173 | } |
| 173 | 174 | |
| 174 | 175 | $form = ' |
| 175 | 176 | <form name="' . esc_attr( $args['form_id'] ) . '" id="' . esc_attr( $args['form_id'] ) . '" class="' . esc_attr( $args['form_classes'] ) . '" action="'. esc_url( wppb_curpageurl() ) .'" method="post"> |
| @@ -190,9 +191,9 @@ | ||
| 190 | 191 | |
| 191 | 192 | ' . $login_form_middle . ' |
| 192 | 193 | ' . ( $args['remember'] ? '<p class="wppb-form-field login-remember"><input name="rememberme" type="checkbox" id="' . esc_attr( $args['id_remember'] ) . '" value="forever"' . ( $args['value_remember'] ? ' checked="checked"' : '' ) . ' /><label for="' . esc_attr( $args['id_remember'] ) . '">' . esc_html( $args['label_remember'] ) . '</label></p>' : '' ) . ' |
| 193 | 194 | <p class="login-submit form-submit"> |
| 194 | - <input type="submit" name="wp-submit" id="' . esc_attr( $args['id_submit'] ) . '" class="'. esc_attr( apply_filters( 'wppb_login_submit_class', "button button-primary" ) ) . '" value="' . esc_attr( $args['label_log_in'] ) . '"' . apply_filters( 'wppb_login_submit_button_extra_attributes', '' ) . '" /> | |
| 195 | + <input type="submit" name="wp-submit" id="' . esc_attr( $args['id_submit'] ) . '" class="'. esc_attr( apply_filters( 'wppb_login_submit_class', "button button-primary" ) ) . '" value="' . esc_attr( $args['label_log_in'] ) . '"' . apply_filters( 'wppb_login_submit_button_extra_attributes', '' ) . ' /> | |
| 195 | 196 | <input type="hidden" name="redirect_to" value="' . esc_url( $args['redirect'] ) . '" /> |
| 196 | 197 | </p> |
| 197 | 198 | <input type="hidden" name="wppb_login" value="true"/> |
| 198 | 199 | <input type="hidden" name="wppb_form_location" value="'. esc_attr( $form_location ) .'"/> |
| @@ -410,9 +411,9 @@ | ||
| 410 | 411 | if( isset( $_POST['wppb_login'] ) ){ |
| 411 | 412 | if( is_wp_error( $user ) ) { |
| 412 | 413 | // if we don't have a successful login we must redirect to the url of the form, so make sure this happens |
| 413 | 414 | if( isset( $_POST['wppb_request_url'] ) ) |
| 414 | - $redirect_to = esc_url_raw( $_POST['wppb_request_url'] ); | |
| 415 | + $redirect_to = wppb_sanitize_request_url( $_POST['wppb_request_url'] ); | |
| 415 | 416 | if( isset( $_POST['wppb_form_location'] ) ) |
| 416 | 417 | $request_form_location = sanitize_text_field( $_POST['wppb_form_location'] ); |
| 417 | 418 | $error_string = $user->get_error_message(); |
| 418 | 419 | |
| @@ -421,10 +422,11 @@ | ||
| 421 | 422 | if (isset($wppb_generalSettings['loginWith'])) { |
| 422 | 423 | |
| 423 | 424 | $lost_pass_url = site_url('/wp-login.php?action=lostpassword'); |
| 424 | 425 | // if the Login shortcode has a lostpassword argument set, give the lost password error link that value |
| 425 | - if (!empty($_POST['wppb_lostpassword_url'])) { | |
| 426 | - $lost_pass_url = esc_url_raw( $_POST['wppb_lostpassword_url'] ); | |
| 426 | + $lost_pass_url_input = wppb_sanitize_request_url( $_POST['wppb_lostpassword_url'] ?? '' ); | |
| 427 | + if ( $lost_pass_url_input !== '' ) { | |
| 428 | + $lost_pass_url = $lost_pass_url_input; | |
| 427 | 429 | if ( wppb_check_missing_http( $lost_pass_url ) ) |
| 428 | 430 | $lost_pass_url = "http://" . $lost_pass_url; |
| 429 | 431 | } |
| 430 | 432 | //apply filter to allow changing Lost your Password link |
| @@ -482,10 +484,11 @@ | ||
| 482 | 484 | $error_string = apply_filters('wppb_login_wp_error_message', $error_string, $user); |
| 483 | 485 | $wppb_error_string_nonce = wp_create_nonce( 'wppb_login_error_'.$error_string ); |
| 484 | 486 | |
| 485 | 487 | // encode the error string and send it as a GET parameter |
| 486 | - if ( isset($_POST['wppb_referer_url']) && $_POST['wppb_referer_url'] !== '' ) { | |
| 487 | - $arr_params = array('loginerror' => urlencode(base64_encode($error_string)), '_wpnonce' => $wppb_error_string_nonce, 'request_form_location' => $request_form_location, 'wppb_referer_url' => urlencode(esc_url_raw( $_POST['wppb_referer_url'] ))); | |
| 488 | + $referer_url = wppb_sanitize_request_url( $_POST['wppb_referer_url'] ?? '' ); | |
| 489 | + if ( $referer_url !== '' ) { | |
| 490 | + $arr_params = array('loginerror' => urlencode(base64_encode($error_string)), '_wpnonce' => $wppb_error_string_nonce, 'request_form_location' => $request_form_location, 'wppb_referer_url' => urlencode( $referer_url )); | |
| 488 | 491 | } else { |
| 489 | 492 | $arr_params = array('loginerror' => urlencode(base64_encode($error_string)), '_wpnonce' => $wppb_error_string_nonce, 'request_form_location' => $request_form_location); |
| 490 | 493 | } |
| 491 | 494 | |
| @@ -627,9 +630,9 @@ | ||
| 627 | 630 | if( wp_verify_nonce( sanitize_text_field( $_GET['_wpnonce'] ), 'wppb_login_error_'. $error_string ) ) { |
| 628 | 631 | if ( isset( $_GET['wppb_message_type'] ) && $_GET['wppb_message_type'] == 'success' ) |
| 629 | 632 | $message_type = 'wppb-success'; |
| 630 | 633 | else $message_type = 'wppb-error'; |
| 631 | - $loginerror = '<p class="'. $message_type .'">' . wp_kses_post(str_replace( '-wppb-plus-', '+', $error_string)) . '</p><!-- .error -->'; | |
| 634 | + $loginerror = '<p class="'. $message_type .'" role="alert">' . wp_kses_post(str_replace( '-wppb-plus-', '+', $error_string)) . '</p><!-- .error -->'; | |
| 632 | 635 | if (isset($_GET['request_form_location'])) { |
| 633 | 636 | if ($_GET['request_form_location'] === 'widget' && !in_the_loop()) { |
| 634 | 637 | $login_form .= $loginerror; |
| 635 | 638 | } elseif ($_GET['request_form_location'] === 'page' && in_the_loop()) { |
| @@ -685,9 +688,9 @@ | ||
| 685 | 688 | } else { |
| 686 | 689 | $display_name = $wppb_user->user_login; |
| 687 | 690 | } |
| 688 | 691 | |
| 689 | - $logged_in_message = '<p class="wppb-alert">'; | |
| 692 | + $logged_in_message = '<p class="wppb-alert" role="alert">'; | |
| 690 | 693 | |
| 691 | 694 | // CHECK FOR REDIRECT |
| 692 | 695 | $logout_redirect_url = wppb_get_redirect_url( $redirect_priority, 'after_logout', $logout_redirect_url, $wppb_user ); |
| 693 | 696 | $logout_redirect_url = apply_filters( 'wppb_after_logout_redirect_url', $logout_redirect_url ); |