Make WordPress Core

Ticket #31645: 31645.7.patch

File 31645.7.patch, 1.3 KB (added by stephdau, 10 years ago)

Same as 31645.diff, but with .patch so it gets renamed with 31645.7.patch upon upload. :)

  • src/wp-admin/includes/class-wp-press-this.php

     
    1818
    1919        private $embeds = array();
    2020
     21        private $url = '';
     22
    2123        /**
    2224         * Constructor.
    2325         *
     
    352354                        return '';
    353355                }
    354356
    355                 return esc_url_raw( $url, array( 'http', 'https' ) );
     357                if ( ! preg_match( '/^https?:/', $url ) && ! empty( $this->url ) ) {
     358                        if ( preg_match( '/^[\/]{1}[^\/]+/', $url ) ) {
     359                                // From root: /blah
     360                                $url = preg_replace( '/^(https?:\/\/[^\/]+)(\/.*)?$/', '\1', $this->url ) . $url;
     361                        } else if ( preg_match( '/^[\/]{2}[^\/]+/', $url ) ) {
     362                                // Protocol relative: //blah.com/blah
     363                                $url = preg_replace( '/^(https?:)\/\/.+$/', '\1', $this->url ) . $url;
     364                        } else {
     365                                // Relative, or different protocol than http, set to already valid $this->url
     366                                $url = $this->url;
     367                        }
     368                }
     369
     370                $url = esc_url_raw( $url, array( 'http', 'https' ) );
     371
     372                return $url;
    356373        }
    357374
    358375        private function _limit_img( $src ) {
     
    597614
    598615                        if ( 'u' === $key ) {
    599616                                $value = $this->_limit_url( $value );
     617                                if ( preg_match( '/^https?:/', $value ) ) {
     618                                        $this->url = $value;
     619                                }
    600620                        } else {
    601621                                $value = $this->_limit_string( $value );
    602622                        }