MDL-80239 grade: escape matched data in user search results.
This commit is contained in:
committed by
Ilya Tregubov
parent
260924aeb8
commit
463f16617e
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -140,15 +140,23 @@ export default class UserSearch extends search_combobox {
|
||||
if (value === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const valueString = value.toString().toLowerCase();
|
||||
if (valueString.includes(this.getPreppedSearchTerm()) && !this.bannedFilterFields.includes(key)) {
|
||||
const preppedSearchTerm = this.getPreppedSearchTerm();
|
||||
const searchTerm = this.getSearchTerm();
|
||||
|
||||
if (valueString.includes(preppedSearchTerm) && !this.bannedFilterFields.includes(key)) {
|
||||
// Ensure we have a good string, otherwise fallback to the key.
|
||||
user.matchingFieldName = stringMap.get(key) ?? key;
|
||||
user.matchingField = valueString.replace(
|
||||
this.getPreppedSearchTerm(),
|
||||
`<span class="font-weight-bold">${this.getSearchTerm()}</span>`
|
||||
|
||||
// Safely prepare our matching results.
|
||||
const escapedValueString = valueString.replace(/</g, '<');
|
||||
const escapedMatchingField = escapedValueString.replace(
|
||||
preppedSearchTerm.replace(/</g, '<'),
|
||||
`<span class="font-weight-bold">${searchTerm.replace(/</g, '<')}</span>`
|
||||
);
|
||||
user.matchingField = `${user.matchingField} (${user.email})`;
|
||||
|
||||
user.matchingField = `${escapedMatchingField} (${user.email})`;
|
||||
user.link = this.selectOneLink(user.id);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user