Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

util: Clarify format_array_as_list_with_highlighted_elements.

Tim Abbott4d4a73c492f6
diff --git a/web/src/util.ts b/web/src/util.ts
index db961aa6144..1eb537c91a4 100644
--- a/web/src/util.ts
+++ b/web/src/util.ts
@@ -465,8 +465,10 @@ export function format_array_as_list_with_highlighted_elements(
const formatted_parts = list_formatter.formatToParts(array);
return formatted_parts
.map((part) => {
+ // There are two types of parts: elements (the actual
+ // items), and literals (commas, etc.). We need to
+ // HTML-escape the elements, but not the literals.
if (part.type === "element") {
- // Only highlight the values passed in array and not commas, etc.
return `<b>${Handlebars.Utils.escapeExpression(part.value)}</b>`;
}
return part.value;