WordPress.org

Make WordPress Core

Changeset 1225 in tests


Ignore:
Timestamp:
02/28/2013 09:02:30 PM (5 years ago)
Author:
nacin
Message:

Test for allowing .. in paths passed to *_url functions. see #19032.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/url.php

    r1034 r1225  
    307307        // cache in get_adjacent_post() requires a fresh page load to invalidate.
    308308    }
     309
     310    /**
     311     * Test that *_url functions handle paths with ".."
     312     *
     313     * @ticket 19032
     314     */
     315    public function test_url_functions_for_dots_in_paths() {
     316        $functions = array(
     317            'site_url',
     318            'home_url',
     319            'admin_url',
     320            'network_admin_url',
     321            'user_admin_url',
     322            'includes_url',
     323            'network_site_url',
     324            'network_home_url',
     325            'content_url',
     326            'plugins_url',
     327        );
     328
     329        foreach ( $functions as $function ) {
     330            $this->assertEquals( call_user_func( $function, '/' ) . '../',
     331                call_user_func( $function, '../' ) );
     332            $this->assertEquals( call_user_func( $function, '/' ) . 'something...here',
     333                call_user_func( $function, 'something...here' ) );
     334        }
     335
     336        // These functions accept a blog ID argument.
     337        foreach ( array( 'get_site_url', 'get_home_url', 'get_admin_url' ) as $function ) {
     338            $this->assertEquals( call_user_func( $function, null, '/' ) . '../',
     339                call_user_func( $function, null, '../' ) );
     340            $this->assertEquals( call_user_func( $function, null, '/' ) . 'something...here',
     341                call_user_func( $function, null, 'something...here' ) );
     342        }
     343    }
    309344}
Note: See TracChangeset for help on using the changeset viewer.