[wp-trac] [WordPress Trac] #25767: get_home_path() fails if admin is SSL and not the frontend

WordPress Trac noreply at wordpress.org
Wed Oct 30 04:09:40 UTC 2013


#25767: get_home_path() fails if admin is SSL and not the frontend
--------------------------+-----------------------------
 Reporter:  GregLone      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  3.7.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 Hello.

 In case you use SSL for the administration area and not the frontend,
 `get_home_path()` will fail to retrieve the home path.
 In this case:
 home url: http://example.com
 site url: https://example.com

 Current version:
 {{{
 function get_home_path() {
         $home = get_option( 'home' );
         $siteurl = get_option( 'siteurl' );
         if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) {
                 $wp_path_rel_to_home = str_ireplace( $home, '', $siteurl
 ); /* $siteurl - $home */
                 $pos = strripos( str_replace( '\\', '/',
 $_SERVER['SCRIPT_FILENAME'] ), trailingslashit( $wp_path_rel_to_home ) );
                 $home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos
 );
                 $home_path = trailingslashit( $home_path );
         } else {
                 $home_path = ABSPATH;
         }

         return str_replace( '\\', '/', $home_path );
 }
 }}}
 All the strings comparison or replacement will fail when they shouldn't.

 Possible patch, remove the protocol:
 {{{
 function get_home_path() {
         $home = get_option( 'home' );
         $siteurl = get_option( 'siteurl' );
         $home = substr( $home, (strpos($home, 'https://') === 0 ? 8 : 7)
 );
         $siteurl = substr( $siteurl, (strpos($siteurl, 'https://') === 0 ?
 8 : 7) );
         if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) {
                 ...
 }}}

 Thanks

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25767>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list