diff --git a/__tests__/src/components/SanitizedHtml.test.js b/__tests__/src/components/SanitizedHtml.test.js index c630c0f730de542f049db6608872a7ca7bfb289f..9d62c9e02d342fe44fa919eb1d13211ff728b0dc 100644 --- a/__tests__/src/components/SanitizedHtml.test.js +++ b/__tests__/src/components/SanitizedHtml.test.js @@ -5,7 +5,7 @@ import SanitizedHtml from '../../../src/components/SanitizedHtml'; const wrapper = shallow( <SanitizedHtml htmlString="<script>doBadThings()</script><b>Don't worry!</b>" - ruleSet="basic" + ruleSet="iiif" />, ); diff --git a/src/lib/htmlRules.js b/src/lib/htmlRules.js index ca5b95dd9e7956234c0cc6870ccdd439f26705dc..30b190428c014a52cc6f44e453803f300212d857 100644 --- a/src/lib/htmlRules.js +++ b/src/lib/htmlRules.js @@ -1,7 +1,27 @@ -const basic = { +// Only remove security related tags and attributes. Allow each other. +const liberal = {}; + +// No html at all. Only text will remain. +const noHtml = { + ALLOWED_TAGS: [], +}; + +// Presentation API 2 suggestion. +const iiif = { + ALLOWED_TAGS: ['a', 'b', 'br', 'i', 'img', 'p', 'span'], + ALLOWED_ATTR: ['href', 'src', 'alt'], +}; + +// Rule set that is used in Mirador 2. +const mirador2 = { ALLOWED_TAGS: ['a', 'b', 'br', 'i', 'img', 'p', 'span', 'strong', 'em', 'ul', 'ol', 'li'], ALLOWED_ATTR: ['href', 'target', 'src', 'alt', 'dir'], }; -export default { basic }; +export default { + liberal, + noHtml, + iiif, + mirador2, +};