Update/Install: Replace "error" and "-1" failure messages with a more meaningful one.
* "-1" is an invalid nonce error, show 'An error has occurred. Please reload the page and try again.'. * "error" means that the connection to the server was lost, show 'Connection lost or the server is busy. Please try again later.'. * Escape the message in `wp-updates-admin-notice` because the response may include HTML. * Remove HTML tags in `wp.updates.isValidResponse()` to make PHP's error messages more readable. Props azaozz for review. Fixes #37583. Built from https://develop.svn.wordpress.org/trunk@38205 git-svn-id: http://core.svn.wordpress.org/trunk@38146 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -1562,8 +1562,12 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( _.isString( response ) ) {
|
||||
if ( _.isString( response ) && '-1' === response ) {
|
||||
error = wp.updates.l10n.nonceError;
|
||||
} else if ( _.isString( response ) ) {
|
||||
error = response;
|
||||
} else if ( 'undefined' !== typeof response.readyState && 0 === response.readyState ) {
|
||||
error = wp.updates.l10n.connectionError;
|
||||
} else if ( _.isString( response.responseText ) && '' !== response.responseText ) {
|
||||
error = response.responseText;
|
||||
} else if ( _.isString( response.statusText ) ) {
|
||||
@@ -1584,6 +1588,8 @@
|
||||
break;
|
||||
}
|
||||
|
||||
// Messages are escaped, remove HTML tags to make them more readable.
|
||||
error = error.replace( /<[\/a-z][^<>]*>/gi, '' );
|
||||
errorMessage = errorMessage.replace( '%s', error );
|
||||
|
||||
// Add admin notice.
|
||||
|
||||
Reference in New Issue
Block a user