mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Make the date in warnings optional for Console (#28995)
Elasticsearch wants to move to remove the warning date from warning headers in deprecation messages that are serialized into response headers. This commit is a step towards enabling Elasticsearch to do that by making the warn date optional in the regular expression used for processing warning headers. This is consistent with RFC 7234 where the warn date can be optional. By making this optional here, Elasticsearch can then follow-up and remove the warn date without breaking Kibana. A follow-up in Kibana can then remove this component from the regular expression instead of leaving it behind as optional.
This commit is contained in:
parent
07af3d4ff1
commit
db481673ee
2 changed files with 16 additions and 1 deletions
|
@ -79,7 +79,7 @@ utils.expandLiteralStrings = function (data) {
|
|||
|
||||
utils.extractDeprecationMessages = function (warnings) {
|
||||
// pattern for valid warning header
|
||||
const re = /\d{3} [0-9a-zA-Z!#$%&'*+-.^_`|~]+ \"((?:\t| |!|[\x23-\x5b]|[\x5d-\x7e]|[\x80-\xff]|\\\\|\\")*)\"(?: \"[^"]*\")/;
|
||||
const re = /\d{3} [0-9a-zA-Z!#$%&'*+-.^_`|~]+ \"((?:\t| |!|[\x23-\x5b]|[\x5d-\x7e]|[\x80-\xff]|\\\\|\\")*)\"(?: \"[^"]*\")?/;
|
||||
// split on any comma that is followed by an even number of quotes
|
||||
return _.map(utils.splitOnUnquotedCommaSpace(warnings), function (warning) {
|
||||
const match = re.exec(warning);
|
||||
|
|
|
@ -55,15 +55,30 @@ describe('Utils class', () => {
|
|||
expect(utils.extractDeprecationMessages(
|
||||
'299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning" "Mon, 27 Feb 2017 14:52:14 GMT"')).toEqual(
|
||||
['#! Deprecation: this is a warning']);
|
||||
expect(utils.extractDeprecationMessages(
|
||||
'299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning"')).toEqual(
|
||||
['#! Deprecation: this is a warning']);
|
||||
|
||||
expect(utils.extractDeprecationMessages( //eslint-disable-next-line max-len
|
||||
'299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning" "Mon, 27 Feb 2017 14:52:14 GMT", 299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a second warning" "Mon, 27 Feb 2017 14:52:14 GMT"')).toEqual(
|
||||
['#! Deprecation: this is a warning', '#! Deprecation: this is a second warning']);
|
||||
expect(utils.extractDeprecationMessages( //eslint-disable-next-line max-len
|
||||
'299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning", 299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a second warning"')).toEqual(
|
||||
['#! Deprecation: this is a warning', '#! Deprecation: this is a second warning']);
|
||||
|
||||
expect(utils.extractDeprecationMessages( //eslint-disable-next-line max-len
|
||||
'299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning, and it includes a comma" "Mon, 27 Feb 2017 14:52:14 GMT"')).toEqual(
|
||||
['#! Deprecation: this is a warning, and it includes a comma']);
|
||||
expect(utils.extractDeprecationMessages( //eslint-disable-next-line max-len
|
||||
'299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning, and it includes a comma"')).toEqual(
|
||||
['#! Deprecation: this is a warning, and it includes a comma']);
|
||||
|
||||
expect(utils.extractDeprecationMessages( //eslint-disable-next-line max-len
|
||||
'299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning, and it includes an escaped backslash \\\\ and a pair of \\\"escaped quotes\\\"" "Mon, 27 Feb 2017 14:52:14 GMT"')).toEqual(
|
||||
['#! Deprecation: this is a warning, and it includes an escaped backslash \\ and a pair of "escaped quotes"']);
|
||||
expect(utils.extractDeprecationMessages( //eslint-disable-next-line max-len
|
||||
'299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning, and it includes an escaped backslash \\\\ and a pair of \\\"escaped quotes\\\""')).toEqual(
|
||||
['#! Deprecation: this is a warning, and it includes an escaped backslash \\ and a pair of "escaped quotes"']);
|
||||
});
|
||||
|
||||
test('unescape', function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue