mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Safer regex handling
If the warning header from Elasticsearch comes back in the wrong format, this could lead to the regex not matching which would lead to a blow-up. While Elasticsearch should not do this, let us be defensive here.
This commit is contained in:
parent
02896eaed7
commit
7f98c48828
1 changed files with 3 additions and 3 deletions
|
@ -181,10 +181,10 @@ export function initializeInput($el, $actionsEl, $copyAsCurlEl, output) {
|
|||
// pattern for valid warning header
|
||||
var re = /\d{3} [^ ]+ \"([^"]*)\"( \"[^"]*\")/
|
||||
// split on any comma that is followed by an even number of quotes
|
||||
warnings = _.map(warnings.split(/, (?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/), function (warning) {
|
||||
warnings = _.map(warnings.split(/, (?=(?:[^"]*\"[^"]*\")*[^"]*$)/), function (warning) {
|
||||
var match = re.exec(warning)
|
||||
// extract the actual warning
|
||||
return "#! Deprecation: " + match[1]
|
||||
// extract the actual warning if there was a match
|
||||
return "#! Deprecation: " + (match !== null ? match[1] : warning)
|
||||
});
|
||||
value = warnings.join("\n") + "\n" + value;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue