mirror of
https://github.com/ansible/awx.git
synced 2026-01-19 05:31:22 -03:30
Merge pull request #3608 from mabashian/host-filter-quotes
Prevents replacing encoded quotes while searching against host filter Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
commit
3521c56baf
@ -18,11 +18,11 @@ function QuerysetService ($q, Rest, ProcessErrors, $rootScope, Wait, DjangoSearc
|
||||
return defer.promise;
|
||||
},
|
||||
getCommonModelOptions(path, name) {
|
||||
let resolve, base,
|
||||
let base,
|
||||
defer = $q.defer();
|
||||
|
||||
this.url = path;
|
||||
resolve = this.options(path)
|
||||
this.options(path)
|
||||
.then((res) => {
|
||||
base = res.data.actions.GET;
|
||||
let relatedSearchFields = res.data.related_search_fields;
|
||||
@ -46,7 +46,7 @@ function QuerysetService ($q, Rest, ProcessErrors, $rootScope, Wait, DjangoSearc
|
||||
replaceEncodedTokens(value) {
|
||||
return decodeURIComponent(value).replace(/"|'/g, "");
|
||||
},
|
||||
encodeTerms(value, key){
|
||||
encodeTerms(value, key, singleSearchParam){
|
||||
key = this.replaceDefaultFlags(key);
|
||||
value = this.replaceDefaultFlags(value);
|
||||
var that = this;
|
||||
@ -54,7 +54,7 @@ function QuerysetService ($q, Rest, ProcessErrors, $rootScope, Wait, DjangoSearc
|
||||
value = _.uniq(_.flattenDeep(value));
|
||||
let concated = '';
|
||||
angular.forEach(value, function(item){
|
||||
if(item && typeof item === 'string') {
|
||||
if(item && typeof item === 'string' && !singleSearchParam) {
|
||||
item = that.replaceEncodedTokens(item);
|
||||
}
|
||||
concated += `${key}=${item}&`;
|
||||
@ -63,7 +63,7 @@ function QuerysetService ($q, Rest, ProcessErrors, $rootScope, Wait, DjangoSearc
|
||||
return concated;
|
||||
}
|
||||
else {
|
||||
if(value && typeof value === 'string') {
|
||||
if(value && typeof value === 'string' && !singleSearchParam) {
|
||||
value = this.replaceEncodedTokens(value);
|
||||
}
|
||||
|
||||
@ -71,10 +71,10 @@ function QuerysetService ($q, Rest, ProcessErrors, $rootScope, Wait, DjangoSearc
|
||||
}
|
||||
},
|
||||
// encodes ui-router params from {operand__key__comparator: value} pairs to API-consumable URL
|
||||
encodeQueryset(params) {
|
||||
encodeQueryset(params, singleSearchParam) {
|
||||
let queryset;
|
||||
queryset = _.reduce(params, (result, value, key) => {
|
||||
return result + this.encodeTerms(value, key);
|
||||
return result + this.encodeTerms(value, key, singleSearchParam);
|
||||
}, '');
|
||||
queryset = queryset.substring(0, queryset.length - 1);
|
||||
return angular.isObject(params) ? `?${queryset}` : '';
|
||||
@ -268,9 +268,9 @@ function QuerysetService ($q, Rest, ProcessErrors, $rootScope, Wait, DjangoSearc
|
||||
Rest.setUrl(endpoint);
|
||||
return Rest.options(endpoint);
|
||||
},
|
||||
search(endpoint, params) {
|
||||
search(endpoint, params, singleSearchParam) {
|
||||
Wait('start');
|
||||
this.url = `${endpoint}${this.encodeQueryset(params)}`;
|
||||
this.url = `${endpoint}${this.encodeQueryset(params, singleSearchParam)}`;
|
||||
Rest.setUrl(this.url);
|
||||
|
||||
return Rest.get()
|
||||
|
||||
@ -202,7 +202,7 @@ function SmartSearchController (
|
||||
});
|
||||
}
|
||||
|
||||
qs.search(path, queryset)
|
||||
qs.search(path, queryset, singleSearchParam)
|
||||
.then(({ data }) => {
|
||||
if ($scope.querySet) {
|
||||
$scope.querySet = queryset;
|
||||
|
||||
@ -14,6 +14,10 @@ export default [function() {
|
||||
let groups = [];
|
||||
let quoted;
|
||||
|
||||
// This split _may_ split search terms down the middle
|
||||
// ex) searchString=ansible_facts.some_other_thing:"foo foobar" ansible_facts.some_thing:"foobar"
|
||||
// would result in 3 different substring's but only two search terms
|
||||
// This logic handles that scenario with the `quoted` variable
|
||||
searchString.split(' ').forEach(substring => {
|
||||
if (/:"/g.test(substring)) {
|
||||
if (/"$/.test(substring)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user