Skip to content

Commit 02896ea

Browse files
committed
Correct display of warning header
Elasticsearch produces warning headers for the use of deprecated features. These warning headers can contain commas which breaks the splitting of multiple values on commas. Upstream Elasticsearch has changed the warning headers to be specification compliant so that these headers can be safely split (the warning text and warning date must be quoted, so splits should only occur on commas that are not contained in quotes). Additionally, the upstream change includes additional details that are not needed for display in Console (a warning code, the Elasticsearch version that produced the warning, and the warning date). This commit corrects the splitting logic in Console to only split on commas not contained in quotes, and to extract the warning text from each warning header.
1 parent 15d1e7c commit 02896ea

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

  • src/core_plugins/console/public/src

src/core_plugins/console/public/src/input.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,13 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output) {
178178

179179
var warnings = xhr.getResponseHeader("warning");
180180
if (warnings) {
181-
warnings = _.map(warnings.split(", "), function (warning) {
182-
return "#! Deprecation: " + warning;
181+
// pattern for valid warning header
182+
var re = /\d{3} [^ ]+ \"([^"]*)\"( \"[^"]*\")/
183+
// split on any comma that is followed by an even number of quotes
184+
warnings = _.map(warnings.split(/, (?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/), function (warning) {
185+
var match = re.exec(warning)
186+
// extract the actual warning
187+
return "#! Deprecation: " + match[1]
183188
});
184189
value = warnings.join("\n") + "\n" + value;
185190
}

0 commit comments

Comments
 (0)