-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: - New term's linter - Enabling `needToSanitizeHtml` by default
- Loading branch information
1 parent
52048c0
commit 92d3501
Showing
21 changed files
with
1,251 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Changelog @diplodoc/transform@4.0.0 | ||
|
||
## It's major update of @doc-tools/transform@3.11.0 with security changes. | ||
|
||
### New term's linter | ||
|
||
The main feature of term is generating a hidden content, that will be show on click. Terms plugins creates MarkadownIt tokens at place, where term was defined and it can brake our `@doc-tools/docs` navigation. Now `@diplodoc/transform` has new yfmlint rule: `no-term-definition-in-content`. There are several restrictions: - You can't define content between term-def - All term-def should be placed at the end of file. | ||
|
||
### Enabling `needToSanitizeHtml` by default | ||
|
||
The sanitizer includes default options with safe, allowed tags, and attributes. However, by default, both the `style` tag and the `style` attribute are also allowed. The values will be processed by the [cssfilter](https://github.com/leizongmin/js-css-filter) module to prevent XSS attacks. The cssfilter module includes a default CSS whitelist. | ||
|
||
You can override the options for sanitizer like this: | ||
|
||
```javascript | ||
const transform = require('@doc-tools/transform'); | ||
const {defaultOptions} = require('@doc-tools/transform/lib/sanitize'); | ||
|
||
const sanitizeOptions = Object.assign({}, defaultOptions); | ||
|
||
// Allow css property | ||
sanitizeOptions.cssWhiteList['position'] = true; | ||
|
||
// Disallow css property | ||
delete sanitizeOptions.cssWhiteList['color']; | ||
|
||
// Disable `style` tag | ||
sanitizeOptions.allowedTags = sanitizeOptions.allowedTags.filter((tag) => tag !== 'style'); | ||
|
||
// Disable `style` attribute | ||
sanitizeOptions.allowedAttributes['*'] = sanitizeOptions.allowedAttributes['*'].filter( | ||
(attr) => attr !== 'style', | ||
); | ||
|
||
const { | ||
result: {html}, | ||
} = transform(content, {sanitizeOptions}); | ||
``` |
Oops, something went wrong.