Making WordPress.org

Changeset 2317


Ignore:
Timestamp:
01/19/2016 01:51:49 AM (11 years ago)
Author:
dd32
Message:

WordPress.org SSO: Use a different regular expression delimiter to promote readable regexes.

File:
1 edited

Legend:

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

    r2316 r2317  
    4343                        add_filter( 'allowed_redirect_hosts', array( &$this, 'add_allowed_redirect_host' ) );
    4444                       
    45                         if ( preg_match( '/\/wp-signup\.php$/', $this->script ) ) {
     45                        if ( preg_match( '!/wp-signup\.php$!', $this->script ) ) {
    4646                                // If we're on any WP signup screen, redirect to the SSO host one,respecting the user's redirect_to request
    4747                                $this->_safe_redirect( add_query_arg( 'redirect_to', urlencode( $redirect_req ), $this->sso_signup_url ) );
    4848                       
    49                         } else if ( self::SSO_HOST !== $this->host ) {
     49                        } elseif ( self::SSO_HOST !== $this->host ) {
    5050                                // If we're not on the SSO host
    51                                 if ( preg_match( '/\/wp-login\.php$/', $this->script ) ) {
     51                                if ( preg_match( '!/wp-login\.php$!', $this->script ) ) {
    5252                                        // If on a WP login screen...
    5353                                        $redirect_to_sso_login = $this->sso_login_url;
     
    7171                        } else if ( self::SSO_HOST === $this->host ) {
    7272                                // If on the SSO host
    73                                 if ( ! preg_match( '/\/wp-login\.php$/', $this->script ) ) {
     73                                if ( ! preg_match( '!/wp-login\.php$!', $this->script ) ) {
    7474                                        // ... but not on its login screen.
    75                                         if ( preg_match( '/^\/(\?.*)?$/', $_SERVER['REQUEST_URI'] ) ) {
     75                                        if ( preg_match( '!^/(\?.*)?$!', $_SERVER['REQUEST_URI'] ) ) {
    7676                                                // If at host root (/)
    7777                                                if ( ! empty( $_GET['action'] ) ) {
     
    9494                                                        }
    9595                                                        return;
    96                                                 } 
    97                                         } else if ( preg_match( '/^\/oauth([\/\?]{1}.*)?$/', $_SERVER['REQUEST_URI'] ) ) {
     96                                                }
     97                                        } elseif ( preg_match( '!^/oauth([/?]{1}.*)?$!', $_SERVER['REQUEST_URI'] ) ) {
    9898                                                // Let the theme render for oauth paths (/oauth, /oauth/, /oauth/*, but
    9999                                                // not /notoauth or /oauthnot), or redirect if logged in
     
    102102                                                }
    103103                                                return;
    104                                         } else  if ( is_user_logged_in() ) {
     104                                        } elseif ( is_user_logged_in() ) {
    105105                                                // Logged in catch all, before last fallback
    106106                                                $this->_redirect_to_profile();
     
    129129                 */
    130130                public function login_network_site_url( $url, $path, $scheme ) {
    131                         if ( self::SSO_HOST === $this->host && preg_match( '/\/wp-login\.php$/', $this->script ) ) {
    132                                 $url = preg_replace( '/^(https?:\/\/)[^\/]+(\/.+)$/' , '\1'.self::SSO_HOST.'\2', $url );
     131                        if ( self::SSO_HOST === $this->host && preg_match( '!/wp-login\.php$!', $this->script ) ) {
     132                                $url = preg_replace( '!^(https?://)[^/]+(/.+)$!' , '\1'.self::SSO_HOST.'\2', $url );
    133133                        }
    134134                       
Note: See TracChangeset for help on using the changeset viewer.