From 045ea512e51aee181b593775819189d02a4f79b9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mathias=20Maa=C3=9F?= <mathias.maass@uni-leipzig.de>
Date: Tue, 19 Feb 2019 11:48:52 +0100
Subject: [PATCH] Create different html rule sets. Part of #1854

---
 .../src/components/SanitizedHtml.test.js      |  2 +-
 src/lib/htmlRules.js                          | 24 +++++++++++++++++--
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/__tests__/src/components/SanitizedHtml.test.js b/__tests__/src/components/SanitizedHtml.test.js
index c630c0f73..9d62c9e02 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 ca5b95dd9..30b190428 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,
+};
-- 
GitLab