Language: TypeScript
Label: safe
CWE: CWE-167 \u2014 Improper Handling of Additional Special Element
The product receives input from an upstream component, but it does not handle or incorrectly handles when an additional unexpected special element is provided.

Code:
    public ngOnChanges() {
        let html = '';

        let markdown = this.markdown;

        const hasExclamation = markdown.indexOf('!') === 0;

        if (hasExclamation) {
            markdown = markdown.substring(1);
        }

        if (!markdown) {
            html = markdown;
        } else if (this.optional && !hasExclamation) {
            html = markdown;
        } else if (this.markdown) {
            html = renderMarkdown(markdown, this.inline);
        }

        const hasHtml = html.indexOf('<') >= 0;

        if (hasHtml) {
            this.renderer.setProperty(this.element.nativeElement, 'innerHTML', html);
        } else {
            this.renderer.setProperty(this.element.nativeElement, 'textContent', html);
        }
    }