Ticket #36638: 36638.5.patch
File 36638.5.patch, 4.5 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
3875 3875 $href = get_bloginfo( 'url' ) . $href; 3876 3876 } 3877 3877 3878 $response = wp_ safe_remote_get( $href, array(3878 $response = wp_remote_get( $href, array( 3879 3879 'timeout' => 15, 3880 3880 // Use an explicit user-agent 3881 3881 'user-agent' => 'WordPress URL Test', 3882 3882 ) ); 3883 3883 3884 $ message = null;3884 $error = false; 3885 3885 3886 3886 if ( is_wp_error( $response ) ) { 3887 $error = $response->get_error_message(); 3888 3889 if ( strpos( $message, 'resolve host' ) !== false ) { 3890 $message = array( 'error' => __( 'Invalid host name.' ) ); 3887 if ( strpos( $response->get_error_message(), 'resolve host' ) !== false ) { 3888 $error = true; 3891 3889 } 3892 3893 wp_send_json_error( $message );3890 } elseif ( wp_remote_retrieve_response_code( $response ) === 404 ) { 3891 $error = true; 3894 3892 } 3895 3893 3896 if ( wp_remote_retrieve_response_code( $response ) === 404) {3897 wp_send_json_error( array( ' error' => __( 'Not found, HTTP error 404.' )) );3894 if ( $error ) { 3895 wp_send_json_error( array( 'httpError' => true ) ); 3898 3896 } 3899 3897 3900 3898 wp_send_json_success(); -
src/wp-includes/js/tinymce/plugins/wplink/plugin.js
94 94 var doingUndoRedoTimer; 95 95 var $ = window.jQuery; 96 96 var urlErrors = {}; 97 var emailRegex = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i; 97 98 98 99 function getSelectedLink() { 99 100 var href, html, … … 155 156 return; 156 157 } 157 158 158 // Early check 159 if ( /^http/i.test( href ) && ! /\.[a-z]{2,63}(\/|$)/i.test( href ) ) { 160 urlErrors[href] = tinymce.translate( 'Invalid host name.' ); 159 if ( /^http/i.test( href ) && ! /^https?:\/\/[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}(\/|$)/i.test( href ) ) { 160 urlErrors[href] = true; 161 161 } 162 162 163 163 if ( urlErrors.hasOwnProperty( href ) ) { … … 179 179 return; 180 180 } 181 181 182 if ( response.data && response.data. error ) {183 urlErrors[href] = response.data.error;182 if ( response.data && response.data.httpError ) { 183 urlErrors[href] = true; 184 184 $link.attr( 'data-wplink-url-error', 'true' ); 185 185 186 186 if ( toolbar && toolbar.visible() ) { 187 toolbar.$el.find( '.wp-link-preview a' ).addClass( 'wplink-url-error' ) .attr( 'title', editor.dom.encode( response.data.error ) );187 toolbar.$el.find( '.wp-link-preview a' ).addClass( 'wplink-url-error' ); 188 188 } 189 189 } 190 190 }); … … 274 274 return; 275 275 } 276 276 277 if ( ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( href ) ) {277 if ( ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( href ) && ! emailRegex.test( href ) ) { 278 278 href = 'http://' + href; 279 279 } 280 280 … … 536 536 537 537 editor.on( 'wptoolbar', function( event ) { 538 538 var linkNode = editor.dom.getParent( event.element, 'a' ), 539 $linkNode, href, edit , title;539 $linkNode, href, edit; 540 540 541 541 if ( typeof window.wpLink !== 'undefined' && window.wpLink.modalOpen ) { 542 542 editToolbar.tempHide = true; … … 561 561 previewInstance.setURL( href ); 562 562 event.element = linkNode; 563 563 event.toolbar = toolbar; 564 title = urlErrors.hasOwnProperty( href ) ? editor.dom.encode( urlErrors[ href ] ) : null;565 564 566 565 if ( $linkNode.attr( 'data-wplink-url-error' ) === 'true' ) { 567 toolbar.$el.find( '.wp-link-preview a' ).addClass( 'wplink-url-error' ) .attr( 'title', title );566 toolbar.$el.find( '.wp-link-preview a' ).addClass( 'wplink-url-error' ); 568 567 } else { 569 toolbar.$el.find( '.wp-link-preview a' ).removeClass( 'wplink-url-error' ) .attr( 'title', null );568 toolbar.$el.find( '.wp-link-preview a' ).removeClass( 'wplink-url-error' ); 570 569 } 571 570 } 572 571 } else if ( editToolbar.visible() ) { -
src/wp-includes/js/wplink.js
2 2 3 3 ( function( $, wpLinkL10n, wp ) { 4 4 var editor, searchTimer, River, Query, correctedURL, linkNode, 5 emailRegexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2, 4}$/i,6 urlRegexp = /^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2, 4}[^ "]*$/i,5 emailRegexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,63}$/i, 6 urlRegexp = /^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,63}[^ "]*$/i, 7 7 inputs = {}, 8 8 rivers = {}, 9 9 isTouch = ( 'ontouchend' in document );