Limit what tooltip content may render - #25250
Conversation
54f932f to
0c2ab41
Compare
|
@sgiehl You said:
I’m not sure about this statement. My feedback is not really a blocker, just to be sure you are aware of the edge cases. first case
if (!tag[0].endsWith('>')) {
return true;
}second caseTwo shapes evade the regex entirely and stay lossy even then: |
Tooltip content now renders through a single transform that keeps only simple inline formatting and no attributes, and shows anything else as text in full. The sanitizers move into a module of their own so they can be unit tested.
A title shown as a tooltip is rendered as HTML, so escape the values interpolated into one for that.
Reported by tzi on the pull request.
0c2ab41 to
ca1ee2d
Compare
The visitor log's action tooltip is escaped once where the plugins' entries are combined, so the carriers other plugins render are covered too, and the report cell tooltip normalises its value before escaping it.
Description
Tooltip content is read back from a
titleattribute, which the browser has already decoded, and jQuery UI then inserts it with.html()— so anything in a title that looks like markup is parsed as markup. That content went throughvueSanitize, the general sanitizer, which is meant for rich snippets and keeps classes anddata-*attributes. A tooltip has no use for either: a title is text with at most a line break and some emphasis.This limits what tooltip content may render to a minimal set of inline elements with no attributes at all (
b,br,em,i,small,span,strong,u). It is a hardening change: it caps what any value that reaches a tooltip can do, independently of how the value got into the title — tracked data, an admin-entered name, or a plugin — and it applies to every title in the product, including templates and plugins that have not been touched.Two things come with it:
<still displays in full.titleinto tooltip content with their own copy of the same two lines, and they did not agree — some sanitized, one escaped — so the same title could behave differently depending on which widget showed it. They now shareCoreHome.tooltipContent, which is also reachable from plain JavaScript aswindow.vueSanitizeTooltip().The sanitizers move into a module of their own so their profiles can be unit-tested, and the unused
classattributes on the visits log tooltip spans are dropped, since attributes are what the profile does not keep. No CSS or JS referenced those classes.A follow-up makes the escaping of the titles themselves consistent (a
tooltipAttrTwig filter and the template migration), so display correctness no longer leans on the text fallback.Verification
<math><mtext><mglyph><style>, a<noscript>breakout,<svg></p><style>,<xmp>,<select><option><style>) and markup the parser hoists into the head: nothing rendered, nothing lost.Checklist
Review