mirror of
https://github.com/grafana/grafana.git
synced 2025-09-26 04:24:13 +08:00
* Escape backslashes in regexps in Loki label browser (#45809, #47039). * Escape values in Loki Query Builder. * Escape more values in Loki Query Builder.
This commit is contained in:

committed by
GitHub

parent
b0f41b9772
commit
f00ffb190c
@ -17,7 +17,7 @@ import { LocalStorageValueProvider } from 'app/core/components/LocalStorageValue
|
||||
|
||||
import { LokiDatasource } from '../datasource';
|
||||
import LokiLanguageProvider from '../language_provider';
|
||||
import { shouldRefreshLabels } from '../language_utils';
|
||||
import { escapeLabelValueInSelector, shouldRefreshLabels } from '../language_utils';
|
||||
import { LokiQuery, LokiOptions } from '../types';
|
||||
|
||||
import { LokiLabelBrowser } from './LokiLabelBrowser';
|
||||
@ -47,17 +47,26 @@ function willApplySuggestion(suggestion: string, { typeaheadContext, typeaheadTe
|
||||
|
||||
case 'context-label-values': {
|
||||
// Always add quotes and remove existing ones instead
|
||||
let suggestionModified = '';
|
||||
|
||||
if (!typeaheadText.match(/^(!?=~?"|")/)) {
|
||||
suggestion = `"${suggestion}`;
|
||||
suggestionModified = '"';
|
||||
}
|
||||
|
||||
suggestionModified += escapeLabelValueInSelector(suggestion, typeaheadText);
|
||||
|
||||
if (DOMUtil.getNextCharacter() !== '"') {
|
||||
suggestion = `${suggestion}"`;
|
||||
suggestionModified += '"';
|
||||
}
|
||||
|
||||
suggestion = suggestionModified;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
}
|
||||
|
||||
return suggestion;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user