1
0
mirror of https://github.com/WordPress/WordPress.git synced 2025-03-30 16:36:59 +02:00

Press This: prepend the site domain to root-relative URLs. Reject other relative URLs.

Part props stephdau, kraftbj. Fixes .
Built from https://develop.svn.wordpress.org/trunk@31818


git-svn-id: http://core.svn.wordpress.org/trunk@31800 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2015-03-18 20:43:27 +00:00
parent b30d15cd4a
commit 4303ea5379
2 changed files with 17 additions and 1 deletions
wp-admin/includes
wp-includes

View File

@ -18,6 +18,8 @@ class WP_Press_This {
private $embeds = array();
private $domain = '';
/**
* Constructor.
*
@ -328,6 +330,16 @@ class WP_Press_This {
return '';
}
// If the URL is root-relative, prepend the protocol and domain name
if ( $url && $this->domain && preg_match( '%^/[^/]+%', $url ) ) {
$url = $this->domain . $url;
}
// Not absolute or protocol-relative URL.
if ( ! preg_match( '%^(?:https?:)?//[^/]+%', $url ) ) {
return '';
}
return esc_url_raw( $url, array( 'http', 'https' ) );
}
@ -573,6 +585,10 @@ class WP_Press_This {
if ( 'u' === $key ) {
$value = $this->_limit_url( $value );
if ( preg_match( '%^(?:https?:)?//[^/]+%i', $value, $domain_match ) ) {
$this->domain = $domain_match[0];
}
} else {
$value = $this->_limit_string( $value );
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-beta1-31817';
$wp_version = '4.2-beta1-31818';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.