Language: TypeScript
Label: vulnerable
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 = '';

        const markdown = this.markdown;

        if (!markdown) {
            html = markdown;
        } else if (this.optional && markdown.indexOf('!') !== 0) {
            html = markdown;
        } else if (this.markdown) {
            const renderer = this.inline ? RENDERER_INLINE : RENDERER_DEFAULT;

            html = marked(this.markdown, { renderer });
        }

        if (!this.html && (!html || html === this.markdown || html.indexOf('<') < 0)) {
            this.renderer.setProperty(this.element.nativeElement, 'textContent', html);
        } else {
            this.renderer.setProperty(this.element.nativeElement, 'innerHTML', html);
        }
    }