mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
TinyMCE, inline link:
- Remove proxying through WordPress to test if an URL exists. - Fix and enhance the regex that tests if the URL is well formed. Fixes #36638. git-svn-id: https://develop.svn.wordpress.org/trunk@38159 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -3886,46 +3886,3 @@ function wp_ajax_search_install_plugins() {
|
||||
|
||||
wp_send_json_success( $status );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for testing if a URL exists.
|
||||
*
|
||||
* Used in the editor.
|
||||
*
|
||||
* @since 4.6.0
|
||||
*/
|
||||
function wp_ajax_test_url() {
|
||||
if ( ! current_user_can( 'edit_posts' ) || ! wp_verify_nonce( $_POST['nonce'], 'wp-test-url' ) ) {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
$href = esc_url_raw( $_POST['href'] );
|
||||
|
||||
// Relative URL
|
||||
if ( strpos( $href, '//' ) !== 0 && in_array( $href[0], array( '/', '#', '?' ), true ) ) {
|
||||
$href = get_bloginfo( 'url' ) . $href;
|
||||
}
|
||||
|
||||
// No redirects
|
||||
$response = wp_safe_remote_get( $href, array(
|
||||
'timeout' => 15,
|
||||
// Use an explicit user-agent
|
||||
'user-agent' => 'WordPress URL Test',
|
||||
) );
|
||||
|
||||
$error = false;
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
if ( strpos( $response->get_error_message(), 'resolve host' ) !== false ) {
|
||||
$error = true;
|
||||
}
|
||||
} elseif ( wp_remote_retrieve_response_code( $response ) === 404 ) {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if ( $error ) {
|
||||
wp_send_json_error( array( 'httpError' => true ) );
|
||||
}
|
||||
|
||||
wp_send_json_success();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user