Make WordPress Core

Ticket #31645: 31645.6.patch

File 31645.6.patch, 1.1 KB (added by azaozz, 10 years ago)
  • src/wp-admin/includes/class-wp-press-this.php

     
    1818
    1919        private $embeds = array();
    2020
     21        private $domain = '';
     22
    2123        /**
    2224         * Constructor.
    2325         *
     
    328330                        return '';
    329331                }
    330332
    331                 return esc_url_raw( $url, array( 'http', 'https' ) );
     333                $url = esc_url_raw( $url, array( 'http', 'https' ) );
     334
     335                // If the URL is root-relative, prepend the protocol and domain name
     336                if ( $url && strlen( $url ) > 2 && $this->domain && $url{0} === '/' && $url{1} !== '/' ) {
     337                        $url = $this->domain . $url;
     338                }
     339
     340                return $url;
    332341        }
    333342
    334343        private function _limit_img( $src ) {
     
    573582
    574583                        if ( 'u' === $key ) {
    575584                                $value = $this->_limit_url( $value );
     585
     586                                if ( preg_match( '%^(?:https?:)?//[^/]+%i', $value, $domain_match ) ) {
     587                                        $this->domain = $domain_match[0];
     588                                }
    576589                        } else {
    577590                                $value = $this->_limit_string( $value );
    578591                        }