Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with sanitizeHtml ([sanitizeHtml]="false") #163

Open
PhilFlash opened this issue Dec 5, 2018 · 0 comments
Open

Bug with sanitizeHtml ([sanitizeHtml]="false") #163

PhilFlash opened this issue Dec 5, 2018 · 0 comments

Comments

@PhilFlash
Copy link

Hi,
When you use [sanitizeHtml]="false", the javascript is declared unsafe.
See https://stackblitz.com/edit/ngx-md-exmaple-cgwjwk

Reason:
In ngx-md.component.ts, 'set data' call onDataChange which use this.sanitizeHtml.
But, sanitizeHtml is not initialized (when you use false).

IMHO, there are two corrections for this problem:

  • declare sanitizeHtml in first (just after the constructor and before 'set path' and 'set data').
    This is the first '@input()' and all is ok.
  • add a timeout in 'set data' (to wait the initialization of sanitizeHtml ) like this:
  @Input()
    set data(value: string) {
      if (value) {
        this._data = value;
        setTimeout(() => {
          this.onDataChange(value);
        });
      }
}

Philippe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant