diff --git a/src/legacy/core_plugins/console/public/src/utils.js b/src/legacy/core_plugins/console/public/src/utils.js index 28821426b618f..1f2c3b9267b74 100644 --- a/src/legacy/core_plugins/console/public/src/utils.js +++ b/src/legacy/core_plugins/console/public/src/utils.js @@ -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); diff --git a/src/legacy/core_plugins/console/public/tests/src/utils.test.js b/src/legacy/core_plugins/console/public/tests/src/utils.test.js index 9577566c3ffa3..a139aa47b911f 100644 --- a/src/legacy/core_plugins/console/public/tests/src/utils.test.js +++ b/src/legacy/core_plugins/console/public/tests/src/utils.test.js @@ -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 () {