Making WordPress.org

Changeset 12237


Ignore:
Timestamp:
11/11/2022 03:36:41 AM (22 months ago)
Author:
dd32
Message:

Login: SSO: In the event that headers have already been sent when we redirect, output a HTML redirect and end the process, do not just return.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/common/includes/wporg-sso/class-wporg-sso.php

    r12232 r12237  
    221221         */
    222222        protected function _safe_redirect( $to, $status = 302 ) {
    223             if ( headers_sent() ) {
    224                 return;
    225             }
    226223
    227224            // When available, sanitize the redirect prior to redirecting.
     
    238235            if ( function_exists( 'apply_filters' ) ) {
    239236                $to = apply_filters( 'wp_redirect', $to, $status );
     237            }
     238
     239            // In the event headers have been sent already, output a HTML redirect.
     240            if ( headers_sent() ) {
     241                if ( function_exists( 'esc_url' ) ) {
     242                    $to = esc_url( $to );
     243                } else {
     244                    // This is not a replacement for esc_url().
     245                    $to = htmlspecialchars( $to, ENT_QUOTES | ENT_SUBSTITUTE );
     246                }
     247
     248                printf(
     249                    '<meta http-equiv="refresh" content="1;url=%1$s" />' .
     250                    '<a href="%1$s">%1$s</a>',
     251                    $to
     252                );
     253                exit;
    240254            }
    241255
     
    245259                preg_match( '/^30(1|2)$/', $status ) ? $status : 302
    246260            );
    247 
    248             die();
     261            exit;
    249262        }
    250263    }
Note: See TracChangeset for help on using the changeset viewer.