Skip to content

Commit

Permalink
feat!: @diplodoc/transform@v4
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
- New term's linter
- Enabling `needToSanitizeHtml` by default
  • Loading branch information
v8tenko authored and yndx-birman committed Sep 22, 2023
1 parent 52048c0 commit 92d3501
Show file tree
Hide file tree
Showing 21 changed files with 1,251 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ jobs:
- uses: yandex-cloud/ui-release-action@main
with:
github-token: ${{ secrets.YC_UI_BOT_GITHUB_TOKEN }}
npm-token: ${{ secrets.YC_UI_BOT_NPM_TOKEN }}
npm-token: ${{ secrets.ROBOT_DATAUI_NPM_TOKEN }}
node-version: 14
38 changes: 38 additions & 0 deletions CHANGELOG.diplodoc.md
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});
```
Loading

0 comments on commit 92d3501

Please sign in to comment.