mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-14 07:48:39 -05:00
Fix host filter parsing
This commit is contained in:
@@ -164,7 +164,7 @@ export default ['$stateParams', '$scope', '$state', 'GetBasePath', 'QuerySet', '
|
||||
let splitTerms;
|
||||
|
||||
if ($scope.singleSearchParam === 'host_filter') {
|
||||
splitTerms = SmartSearchService.splitHostIntoTerms(terms);
|
||||
splitTerms = SmartSearchService.splitFilterIntoTerms(terms);
|
||||
} else {
|
||||
splitTerms = SmartSearchService.splitSearchIntoTerms(terms);
|
||||
}
|
||||
|
||||
@@ -6,10 +6,14 @@ export default [function() {
|
||||
* work is done to encode quotes in quoted values and the spaces within those quoted
|
||||
* values before calling to `splitSearchIntoTerms`.
|
||||
*/
|
||||
splitHostIntoTerms (searchString) {
|
||||
splitFilterIntoTerms (searchString) {
|
||||
let groups = [];
|
||||
let quoted;
|
||||
|
||||
if (!searchString.includes(' ')) {
|
||||
return this.splitSearchIntoTerms(this.encode(searchString));
|
||||
}
|
||||
|
||||
searchString.split(' ').forEach(substring => {
|
||||
if (substring.includes(':"')) {
|
||||
quoted = substring;
|
||||
@@ -17,9 +21,7 @@ export default [function() {
|
||||
quoted += ` ${substring}`;
|
||||
|
||||
if (substring.includes('"')) {
|
||||
quoted = quoted.replace(/"/g, encodeURIComponent('"'));
|
||||
quoted = quoted.replace(/ /g, encodeURIComponent(' '));
|
||||
groups.push(quoted);
|
||||
groups.push(this.encode(quoted));
|
||||
quoted = undefined;
|
||||
}
|
||||
} else {
|
||||
@@ -29,6 +31,11 @@ export default [function() {
|
||||
|
||||
return this.splitSearchIntoTerms(groups.join(' '));
|
||||
},
|
||||
encode (string) {
|
||||
string = string.replace(/'/g, '%27');
|
||||
|
||||
return string.replace(/("| )/g, match => encodeURIComponent(match));
|
||||
},
|
||||
splitSearchIntoTerms(searchString) {
|
||||
return searchString.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user