Skip to content

Need more thorough escape strategy for special characters #135

Description

@tylerperyea

facetsFromParams() {
if (this.facetString !== '') {
const categoryArray = this.facetString.split(',');
for (let i = 0; i < (categoryArray.length); i++) {
const categorySplit = categoryArray[i].split('*');
const category = categorySplit[0];
const fieldsArr = categorySplit[1].split('+');
const params: { [facetValueLabel: string]: boolean } = {};
let hasSelections = false;
let isAllMatch = false;
let hasExcludeOption = false;
let includeOptionsLength = 0;
for (let j = 0; j < fieldsArr.length; j++) {
const field = fieldsArr[j].split('.');
field[0] = decodeURIComponent(field[0]);
if (field[0] === 'is_all_match') {
isAllMatch = true;
} else {
if (field[1] === 'true') {
params[field[0]] = true;
hasSelections = true;
includeOptionsLength++;
} else if (field[1] === 'false') {
params[field[0]] = false;
hasSelections = true;
hasExcludeOption = true;
}
}
}
if (hasSelections === true) {
this.facetBuilder[category] = { params: params, hasSelections: true, isAllMatch: isAllMatch };
if (!hasExcludeOption && includeOptionsLength > 1) {
this.facetBuilder[category].showAllMatchOption = true;
}
const paramsString = JSON.stringify(params);
const newHash = this.utilsService.hashCode(paramsString,
this.facetBuilder[category].isAllMatch.toString(),
this.showDeprecated.toString());
this.facetBuilder[category].currentStateHash = newHash;
}
}
this.privateFacetParams = this.facetBuilder;
this.previousFacets.push(JSON.parse(JSON.stringify(this.privateFacetParams)));
}
}

This section of the code ends up using "*", ",", "+", and "." in special ways. However, it's not uncommon for facet values to have any/each of these characters. There needs to be a strategy to encode them.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions