Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #21468: #4393

Merged
merged 1 commit into from
Jul 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,29 @@ displayAccountDescription a =
][ i[class "fa fa-"][] ]


-- WARNING:
--
-- Here we are building an html snippet that will be placed inside an attribute, so
-- we can't easily use the Html type as there is no built-in way to serialize it manually.
-- This means it will be vulnerable to XSS on its parameters (here the description).
--
-- We resort to escaping it manually here.
buildTooltipContent : String -> String -> String
buildTooltipContent title content =
let
headingTag = "<h4 class='tags-tooltip-title'>"
contentTag = "</h4><div class='tooltip-inner-content'>"
closeTag = "</div>"
escapedTitle = htmlEscape title
escapedContent = htmlEscape content
in
headingTag ++ title ++ contentTag ++ content ++ closeTag
headingTag ++ escapedTitle ++ contentTag ++ escapedContent ++ closeTag

htmlEscape : String -> String
htmlEscape s =
String.replace "&" "&amp;" s
|> String.replace ">" "&gt;"
|> String.replace "<" "&lt;"
|> String.replace "\"" "&quot;"
|> String.replace "'" "&#x27;"
|> String.replace "\\" "&#x2F;"