Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
97906486
Unverified
Commit
97906486
authored
3 years ago
by
Noah Moss
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Escape HTML in markdown cards when rendered for emails (#18000)
parent
42e2bda8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/pulse/markdown.clj
+5
-1
5 additions, 1 deletion
src/metabase/pulse/markdown.clj
test/metabase/pulse/markdown_test.clj
+24
-0
24 additions, 0 deletions
test/metabase/pulse/markdown_test.clj
with
29 additions
and
1 deletion
src/metabase/pulse/markdown.clj
+
5
−
1
View file @
97906486
...
...
@@ -10,6 +10,7 @@
com.vladsch.flexmark.html.HtmlRenderer
com.vladsch.flexmark.parser.Parser
[
com.vladsch.flexmark.util.ast
Document
Node
]
com.vladsch.flexmark.util.data.MutableDataSet
java.net.URI
))
;;; +----------------------------------------------------------------------------------------------------------------+
...
...
@@ -300,7 +301,10 @@
(
def
^
:private
renderer
"An instance of a Flexmark HTML renderer"
(
delay
(
.build
(
HtmlRenderer/builder
))))
(
let
[
options
(
..
(
MutableDataSet.
)
(
set
(
.
HtmlRenderer
ESCAPE_HTML
)
true
)
(
toImmutable
))]
(
delay
(
.build
(
HtmlRenderer/builder
options
)))))
(
defmulti
process-markdown
"Converts a markdown string from a virtual card into a form that can be sent to a channel
...
...
This diff is collapsed.
Click to expand it.
test/metabase/pulse/markdown_test.clj
+
24
−
0
View file @
97906486
...
...
@@ -157,3 +157,27 @@
(
is
(
=
"&"
(
mrkdwn
"&"
)))
(
is
(
=
">"
(
mrkdwn
">"
)))
(
is
(
=
"ℋ"
(
mrkdwn
"ℋ"
)))))
(
defn-
html
[
markdown
]
(
md/process-markdown
markdown
:html
))
(
deftest
process-markdown-email-test
(
testing
"HTML is generated correctly from Markdown input for emails. Not an exhaustive test suite since parsing and
rendering is fully handled by flexmark."
(
is
(
=
"<h1>header</h1>\n"
(
html
"# header"
)))
(
is
(
=
"<p><strong>bold</strong></p>\n"
(
html
"**bold**"
)))
(
is
(
=
"<p><a href=\"https://metabase.com\" title=\"tooltip\">Metabase</a></p>\n"
(
html
"[Metabase](https://metabase.com \"tooltip\")"
)))
(
is
(
=
"<ol>\n<li>foo\n<ol>\n<li>bar</li>\n</ol>\n</li>\n</ol>\n"
(
html
"1. foo\n 1. bar"
)))
(
is
(
=
"<p>/</p>\n"
(
html
"\\/"
)))
(
is
(
=
"<p><img src=\"image.png\" alt=\"alt-text\" /></p>\n"
(
html
""
))))
(
testing
"HTML in the source markdown is escaped properly, but HTML entities are retained"
(
is
(
=
"<p><h1>header</h1></p>\n"
(
html
"<h1>header</h1>"
)))
(
is
(
=
"<p>&</p>\n"
(
html
"&"
)))))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment