File tree Expand file tree Collapse file tree 1 file changed +32
-1
lines changed
Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -2,12 +2,43 @@ import config from '../../common/config';
22import { getClient } from '../../common/elasticsearch_client' ;
33
44
5+ function escapeLuceneSyntax ( str ) {
6+ return [ ] . map
7+ . call ( str , char => {
8+ if (
9+ char === '/' ||
10+ char === '+' ||
11+ char === '-' ||
12+ char === '&' ||
13+ char === '|' ||
14+ char === '!' ||
15+ char === '(' ||
16+ char === ')' ||
17+ char === '{' ||
18+ char === '}' ||
19+ char === '[' ||
20+ char === ']' ||
21+ char === '^' ||
22+ char === '"' ||
23+ char === '~' ||
24+ char === '*' ||
25+ char === '?' ||
26+ char === ':' ||
27+ char === '\\'
28+ ) {
29+ return `\\${ char } ` ;
30+ }
31+ return char ;
32+ } )
33+ . join ( '' ) ;
34+ }
35+
536function getQueryString ( request ) {
637 if ( request . params . type === 'elastalert_error' ) {
738 return '*:*' ;
839 }
940 else {
10- return `rule_name:${ request . query . rule_name || '*' } ` ;
41+ return `rule_name:" ${ escapeLuceneSyntax ( request . query . rule_name ) || '*' } " ` ;
1142 }
1243}
1344
You can’t perform that action at this time.
0 commit comments