-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Schema ancestors are not respected #8
Comments
I pushed a test that checks that your actual behavior works: syntax-tree/hast-util-sanitize@3068a46. |
It seems to work if using |
I doubt that rehype is doing anything weird: https://github.com/rehypejs/rehype-sanitize/blob/a6ddc5eee07b7e2bdbeed1e9d9e9f045989bd9ec/index.js Can you provide a reproduction? |
You’re right, it’s the |
Reproduction code: const rehype = require('rehype');
const sanitize = require('rehype-sanitize');
const schema = {
"ancestors": {
"li": ["ul"]
},
"tagNames": [
"div",
"ul",
"li"
]
};
const html = `<div>
<li>List Item</li>
</div>`;
(async function run() {
const vfile = await rehype().use(sanitize, schema).process(html);
})(); |
thanks, released a fix! |
Subject of the issue
A schemas
ancestors
property is not respected.Your environment
Steps to reproduce
Simple schema:
HTML:
Expected behavior
Expecting the resulting tree to exclude the
li
tag:Actual behavior
The
li
tag is still included:I investigated a bit and it seems like this bug has appeared because of this: syntax-tree/hast-util-sanitize@19631bb#diff-92bbac9a308cd5fcf9db165841f2d90ce981baddcb2b1e26cfff170929af3bd1R252. I can create a PR for it if you want.
The text was updated successfully, but these errors were encountered: