Ticket #36638: 36638.7.patch
File 36638.7.patch, 6.2 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
3880 3880 $href = get_bloginfo( 'url' ) . $href; 3881 3881 } 3882 3882 3883 $response = wp_ safe_remote_get( $href, array(3883 $response = wp_remote_get( $href, array( 3884 3884 'timeout' => 15, 3885 3885 // Use an explicit user-agent 3886 3886 'user-agent' => 'WordPress URL Test', 3887 3887 ) ); 3888 3888 3889 $ message = null;3889 $error = false; 3890 3890 3891 3891 if ( is_wp_error( $response ) ) { 3892 $error = $response->get_error_message(); 3893 3894 if ( strpos( $message, 'resolve host' ) !== false ) { 3895 $message = array( 'error' => __( 'Invalid host name.' ) ); 3892 if ( strpos( $response->get_error_message(), 'resolve host' ) !== false ) { 3893 $error = true; 3896 3894 } 3897 3898 wp_send_json_error( $message );3895 } elseif ( wp_remote_retrieve_response_code( $response ) === 404 ) { 3896 $error = true; 3899 3897 } 3900 3898 3901 if ( wp_remote_retrieve_response_code( $response ) === 404) {3902 wp_send_json_error( array( ' error' => __( 'Not found, HTTP error 404.' )) );3899 if ( $error ) { 3900 wp_send_json_error( array( 'httpError' => true ) ); 3903 3901 } 3904 3902 3905 3903 wp_send_json_success(); -
src/wp-includes/class-wp-editor.php
1065 1065 'Ctrl + letter:' => __( 'Ctrl + letter:' ), 1066 1066 'Letter' => __( 'Letter' ), 1067 1067 'Action' => __( 'Action' ), 1068 'Invalid host name.' => __( 'Invalid host name.' ), 1068 /* translators: link URL */ 1069 'Error: %s cannot be reached.' => __( 'Error: %s cannot be reached.' ), 1069 1070 'To move focus to other buttons use Tab or the arrow keys. To return focus to the editor press Escape or use one of the buttons.' => 1070 1071 __( 'To move focus to other buttons use Tab or the arrow keys. To return focus to the editor press Escape or use one of the buttons.' ), 1071 1072 'When starting a new paragraph with one of these formatting shortcuts followed by a space, the formatting will be applied automatically. Press Backspace or Escape to undo.' => -
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, … … 147 148 }); 148 149 } 149 150 151 function setLinkError( $link ) { 152 var href = $link.attr( 'href' ); 153 154 $link.attr( 'data-wplink-url-error', 'true' ); 155 156 if ( window.wp && window.wp.a11y && window.wp.a11y.speak ) { 157 window.wp.a11y.speak( editor.translate( 'Error: %s cannot be reached.' ).replace( '%s', href ) ); 158 } 159 160 if ( toolbar && toolbar.visible() ) { 161 toolbar.$el.find( '.wp-link-preview a' ).addClass( 'wplink-url-error' ); 162 } 163 } 164 150 165 function checkLink( node ) { 151 166 var $link = editor.$( node ); 152 167 var href = $link.attr( 'href' ); … … 155 170 return; 156 171 } 157 172 158 // Early check 159 if ( /^http/i.test( href ) && ! /\.[a-z]{2,63}(\/|$)/i.test( href ) ) { 160 urlErrors[href] = tinymce.translate( 'Invalid host name.' ); 173 if ( /^http/i.test( href ) && ! /^https?:\/\/[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}(\/|$)/i.test( href ) ) { 174 urlErrors[href] = true; 161 175 } 162 176 163 177 if ( urlErrors.hasOwnProperty( href ) ) { 164 $link.attr( 'data-wplink-url-error', 'true');178 setLinkError( $link ); 165 179 return; 166 180 } else { 167 181 $link.removeAttr( 'data-wplink-url-error' ); … … 179 193 return; 180 194 } 181 195 182 if ( response.data && response.data.error ) { 183 urlErrors[href] = response.data.error; 184 $link.attr( 'data-wplink-url-error', 'true' ); 185 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 ) ); 188 } 196 if ( response.data && response.data.httpError ) { 197 urlErrors[href] = true; 198 setLinkError( $link ); 189 199 } 190 200 }); 191 201 } … … 274 284 return; 275 285 } 276 286 277 if ( ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( href ) ) {287 if ( ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( href ) && ! emailRegex.test( href ) ) { 278 288 href = 'http://' + href; 279 289 } 280 290 … … 536 546 537 547 editor.on( 'wptoolbar', function( event ) { 538 548 var linkNode = editor.dom.getParent( event.element, 'a' ), 539 $linkNode, href, edit , title;549 $linkNode, href, edit; 540 550 541 551 if ( typeof window.wpLink !== 'undefined' && window.wpLink.modalOpen ) { 542 552 editToolbar.tempHide = true; … … 561 571 previewInstance.setURL( href ); 562 572 event.element = linkNode; 563 573 event.toolbar = toolbar; 564 title = urlErrors.hasOwnProperty( href ) ? editor.dom.encode( urlErrors[ href ] ) : null;565 574 566 575 if ( $linkNode.attr( 'data-wplink-url-error' ) === 'true' ) { 567 toolbar.$el.find( '.wp-link-preview a' ).addClass( 'wplink-url-error' ) .attr( 'title', title );576 toolbar.$el.find( '.wp-link-preview a' ).addClass( 'wplink-url-error' ); 568 577 } else { 569 toolbar.$el.find( '.wp-link-preview a' ).removeClass( 'wplink-url-error' ) .attr( 'title', null );578 toolbar.$el.find( '.wp-link-preview a' ).removeClass( 'wplink-url-error' ); 570 579 } 571 580 } 572 581 } 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 );