Skip to content

Commit c47ba20

Browse files
committed
refactor(readme): add XSS note in readme, closes #29
1 parent 1d61a16 commit c47ba20

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

readme.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,18 @@ export class TestComponent implements OnInit {
215215
}
216216
```
217217

218+
### Security - Dealing with Cross Site Scripting (XSS)
219+
If you want to use this package for any type of users, you should consider sanatizing your data for Cross Site Scripting (XSS) attack. A good package to use for sanitizing is [DOMPurify](https://www.npmjs.com/package/dompurify) and you should sanitize your data when calling the `parser` as shown below. Also if you have any Markdown Preview, remember to sanitize them as well probably via the form input or control.
220+
221+
```ts
222+
this.editorOptions = {
223+
parser: (val: string) => {
224+
const sanitizedText = DOMPurify.sanitize(val.trim());
225+
this.markdownService.compile(sanitizedText);
226+
}
227+
};
228+
```
229+
218230
### Additional Editor Buttons
219231
I really thought that some buttons were missing to go a great job (~~Strikethrough~~ & **Table**). So I added them directly in the [Global Options](https://github.com/ghiscoding/angular-markdown-editor/blob/master/src/lib/angular-markdown-editor/global-editor-options.ts). If you want to add your own, then just look at how it was done in the [Global Options](https://github.com/ghiscoding/angular-markdown-editor/blob/master/src/lib/angular-markdown-editor/global-editor-options.ts) and read the section `additionalButtons` of [Bootstrap Markdown](http://www.codingdrama.com/bootstrap-markdown/) website.
220232

0 commit comments

Comments
 (0)