From 815fc4bfa1be5f1fa46c921b309270c4675d7052 Mon Sep 17 00:00:00 2001 From: jolheiser Date: Tue, 3 Dec 2019 11:13:05 -0600 Subject: [PATCH 1/2] Allow kbd tags Signed-off-by: jolheiser --- modules/markup/sanitizer.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/markup/sanitizer.go b/modules/markup/sanitizer.go index 45d363b37ee3a..0ebb3ff88b035 100644 --- a/modules/markup/sanitizer.go +++ b/modules/markup/sanitizer.go @@ -47,6 +47,9 @@ func ReplaceSanitizer() { // Allow keyword markup sanitizer.policy.AllowAttrs("class").Matching(regexp.MustCompile(`^` + keywordClass + `$`)).OnElements("span") + + // Allow tags for keyboard shortcut styling + sanitizer.policy.AllowElements("kbd") } // Sanitize takes a string that contains a HTML fragment or document and applies policy whitelist. From 5536dac75ba89d76cd2ebe95b0c7950a5cd9b7a6 Mon Sep 17 00:00:00 2001 From: jolheiser Date: Tue, 3 Dec 2019 11:21:42 -0600 Subject: [PATCH 2/2] Add test Signed-off-by: jolheiser --- modules/markup/sanitizer_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/markup/sanitizer_test.go b/modules/markup/sanitizer_test.go index 211201d201ca8..be7bdd20e7e39 100644 --- a/modules/markup/sanitizer_test.go +++ b/modules/markup/sanitizer_test.go @@ -35,6 +35,9 @@ func Test_Sanitizer(t *testing.T) { Hello there! Something has gone wrong, we are working on it. In the meantime, play a game with us at example.com. `, "\n\u00a0\n\nHello there! Something has gone wrong, we are working on it.\nIn the meantime, play a game with us at\u00a0example.com.\n", + + // tags + `Ctrl + C`, `Ctrl + C`, } for i := 0; i < len(testCases); i += 2 {