2
0
mirror of https://github.com/tenrok/BBob.git synced 2026-06-17 19:21:20 +03:00

fix(html): escape bad html (#67)

* feat(preset-html5): add feature to filter javascript: urls

* fix(plugin-helper): escape html in attrs

* fix(plugin-helper): tests for html escape

* refactor(preset-html5): remove html escape from preset

* feat(preset): add ability to pass and extend preset options
This commit is contained in:
Nikolay Kostyurin
2020-07-05 15:23:22 +02:00
committed by GitHub
parent ba090bf997
commit 87f38fe97e
5 changed files with 63 additions and 15 deletions
@@ -1,5 +1,5 @@
/* eslint-disable no-plusplus,no-lonely-if */
import { isStringNode, isTagNode, getUniqAttr } from '@bbob/plugin-helper';
import { getUniqAttr, isStringNode, isTagNode } from '@bbob/plugin-helper';
import TagNode from '@bbob/plugin-helper/lib/TagNode';
const isStartsWith = (node, type) => (node[0] === type);
@@ -55,6 +55,10 @@ const asListItems = (content) => {
return [].concat(listItems);
};
const renderUrl = (node, render) => (getUniqAttr(node.attrs)
? getUniqAttr(node.attrs)
: render(node.content));
export default {
b: (node) => ({
tag: 'span',
@@ -84,10 +88,10 @@ export default {
},
content: node.content,
}),
url: (node, { render }) => ({
url: (node, { render }, options) => ({
tag: 'a',
attrs: {
href: getUniqAttr(node.attrs) ? getUniqAttr(node.attrs) : render(node.content),
href: renderUrl(node, render, options),
},
content: node.content,
}),