Press This: prepend the site domain to root-relative URLs. Reject other relative URLs.
Part props stephdau, kraftbj. Fixes #31645. git-svn-id: https://develop.svn.wordpress.org/trunk@31818 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
25a5f07d51
commit
1a067a5e4c
|
@ -18,6 +18,8 @@ class WP_Press_This {
|
||||||
|
|
||||||
private $embeds = array();
|
private $embeds = array();
|
||||||
|
|
||||||
|
private $domain = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
@ -328,6 +330,16 @@ class WP_Press_This {
|
||||||
return '';
|
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' ) );
|
return esc_url_raw( $url, array( 'http', 'https' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,6 +585,10 @@ class WP_Press_This {
|
||||||
|
|
||||||
if ( 'u' === $key ) {
|
if ( 'u' === $key ) {
|
||||||
$value = $this->_limit_url( $value );
|
$value = $this->_limit_url( $value );
|
||||||
|
|
||||||
|
if ( preg_match( '%^(?:https?:)?//[^/]+%i', $value, $domain_match ) ) {
|
||||||
|
$this->domain = $domain_match[0];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$value = $this->_limit_string( $value );
|
$value = $this->_limit_string( $value );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue