Language: TypeScript
Label: safe
CWE: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.

Code:
export function highlightFilterElements(
    content: string | number | undefined,
    search: string | number | undefined
): UpdateFunctionWithMethods<unknown> {
    const text_content = content?.toString();
    if (
        text_content === "" ||
        text_content === undefined ||
        search === "" ||
        search === undefined
    ) {
        return html`${text_content}`;
    }

    const classifier = Classifier(search.toString());
    const templates = classifier.classify(text_content).map((highlighted_text) => {
        if (!HighlightedText.isHighlight(highlighted_text)) {
            return html`${highlighted_text.content}`;
        }
        return html`<span class="highlight">${highlighted_text.content}</span>`;
    });
    return html`${templates}`;
}