Repository navigation
fix(ui): show the line breaks of data-html popovers as text - #16395
Open
cristianchiriac wants to merge 1 commit into
Open
cristianchiriac wants to merge 1 commit into
cristianchiriac wants to merge 1 commit into
Conversation
Since the classic Bootstrap UI was removed, .has-popover elements are shown by the CSS ::after tooltip and the popover shim in index.js, and both display data-content as plain text. Popovers written for Bootstrap with data-html="true" (the endpoint/location list of a finding, the finding group titles, CVSS vectors, engagement and GitHub summaries) showed their raw <br/> and <b> tags. On page load, turn the <br> of these popovers into newlines, drop their <b> tags, and show them with white-space: pre-line (tooltip) or pre (shim). Everything else, such as markup in an endpoint or a title, stays literal text. Fixes DefectDojo#16393
cristianchiriac
requested review from
Maffooch and
blakeaowens
as code owners
October 17, 2026 09:03
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #16393.
Since the classic Bootstrap UI was removed (#15565),
.has-popoverelements are shown by two things: the CSS::aftertooltip incomponents/tailwind.css(content: attr(data-content)), and the$.fn.popovershim indojo/static/dojo/js/index.js(pop.textContent = content, used by the hover handlers inview_test.htmlandfindings_list_snippet.html). Both showdata-contentas plain text. The popovers that were written for Bootstrap withdata-html="true"therefore show their markup. That's the screenshot in the issue: the endpoint list of a finding renders as✓ host <br/> ✕ host <br/> ..., once in the dark CSS tooltip and once in the white shim box.There are 10 such popovers in 4 templates: endpoints/locations in
findings_list_snippet.htmlandview_test.html, finding group titles inview_test.html, CVSS vectors inview_finding.html, and the engagement and GitHub summaries inproduct.html.This keeps the templates as they are:
index.js: onDOMContentLoaded, for.has-popover[data-html="true"], splitdata-contenton<br>, drop<b>/</b>, collapse each line's whitespace and join the lines with\n. The content is never parsed as HTML. Anything else, such as markup inside an endpoint or a finding title, stays literal text, as it does in every other popover. This runs before the existing accessibility block, so thearia-labelcopied fromdata-contentis the cleaned text too.white-space: prefor those elements (it staysnowrapfor the others).components/tailwind.css: a rule next to the existing::aftertooltip givesdata-html="true"popoverswhite-space: pre-line.tailwind-out.cssis rebuilt withnpx @tailwindcss/cli -i tailwind.css -o ../dojo/static/dojo/css/tailwind-out.css --minify(4.3.3 fromyarn.lock). On unchangeddevthat command reproduces the committed file exactly, and the only change it makes is the new rule.Test results
There are no JS tests for
index.js, so I checked it in a browser (Chromium) with a page that loads jQuery,tailwind-out.cssandindex.jsfromdevand from this branch, with markup copied from the templates: an endpoint popover whose last endpoint is<img src=x onerror="document.title='XSS'">(escaped in the attribute, as Django renders it), the engagement popover fromproduct.html, and a plain file-path popover. I focused each icon to trigger:focus::after, then called.popover('show'):dev:data-content, the::aftercontent and the shim text all contain the raw<br/>/<b>with the template indentation.data-contentis✓ https://app.example.com/login\n✕ vdi-pw11-30\n✕ <img src=x onerror="document.title='XSS'">, the::aftercomputedwhite-spaceispre-line, and the shim box has the same text withwhite-space: pre, no child elements, no image loaded and the document title unchanged. The engagement popover reads3 Active, 1 Closed\nLast Assessed: Oct. 10, 2026, and the plain popover is unchanged (white-space: normal/nowrap).Documentation
No user-facing documentation change.