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

Replace YUI tooltips with Tippy.js #6408

Merged
merged 120 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
0ff896b
Add yarn deps
janfaracik Mar 15, 2022
db1928d
Add initial JS files
janfaracik Mar 15, 2022
09e9109
WB
janfaracik Mar 15, 2022
491b1f1
Update hudson-behavior.js
janfaracik Mar 15, 2022
1fbcc55
Update tooltips.less
janfaracik Mar 15, 2022
940d51a
WB
janfaracik Mar 15, 2022
7e6c576
Fix tooltip showing when it shouldn't, improve appearance
janfaracik Mar 15, 2022
df6847a
Now possible to reregister tooltips
janfaracik Mar 15, 2022
7e43dfa
Update buildHealth.jelly
janfaracik Mar 15, 2022
133c486
Update header tooltips, add base tooltip styling
janfaracik Mar 15, 2022
7223890
Add percentage symbol
janfaracik Mar 15, 2022
22f300a
Merge branch 'master' into tippy-1-tooltip
janfaracik Mar 17, 2022
9be65d6
Update prototype.js
janfaracik Mar 18, 2022
60e4232
Update tooltips.js
janfaracik Mar 18, 2022
93632d3
Merge branch 'master' into tippy-1-tooltip
janfaracik Mar 22, 2022
bfce09a
Fix new lines in tooltips, fix empty tooltips showing
janfaracik Mar 27, 2022
f7659aa
Fix last build successful from having a title
janfaracik Mar 27, 2022
d5608a1
Fix new line in queue tooltip
janfaracik Mar 28, 2022
32d790a
Now possible to reregister tooltips for a specific container
janfaracik Mar 28, 2022
7c52bc0
Merge branch 'master' into tippy-1-tooltip
janfaracik Mar 29, 2022
9365c34
Fix 1 test
timja Mar 30, 2022
68b0aea
Fix hetero list tooltip
janfaracik Mar 30, 2022
43d61dd
Remove escaping for tooltip
janfaracik Mar 30, 2022
b5c0656
Make html-tooltips interactive
janfaracik Apr 4, 2022
2a9e85c
Fix backdrop filter for Firefox, fix table squared corners in Firefox…
janfaracik Apr 6, 2022
684956a
Remove SVG tooltip test as all tooltips are escaped by default
janfaracik Apr 6, 2022
468cbcf
Remove more
janfaracik Apr 6, 2022
4fd7150
Use background colour for tooltip bg
janfaracik Apr 6, 2022
78eef78
Fix unit test
janfaracik Apr 7, 2022
16fe806
Update RepeatableTest.java
janfaracik Apr 8, 2022
9ff6c65
Update RepeatableTest.java
janfaracik Apr 8, 2022
ef041dc
Merge branch 'master' into tippy-1-tooltip
timja Apr 8, 2022
1e8b7b8
Update new line replacement list
janfaracik Apr 12, 2022
4d62a20
Set title for screenreaders, remove on interactino
janfaracik Apr 12, 2022
a552b93
Merge branch 'tippy-1-tooltip' of https://github.com/janfaracik/jenki…
janfaracik Apr 12, 2022
0f33db2
Merge branch 'master' into tippy-1-tooltip
janfaracik Apr 14, 2022
ec3c851
Create yarn.lock
janfaracik Apr 14, 2022
daaa710
Attempt at passing build
janfaracik Apr 14, 2022
228c1fa
Fix JS (htmlunit is not my friend)
janfaracik Apr 17, 2022
cf491b1
Merge branch 'master' into tippy-1-tooltip
janfaracik Apr 17, 2022
bbc1528
Update tooltips.js
janfaracik Apr 17, 2022
0be118f
Merge branch 'master' into tippy-1-tooltip
NotMyFault Apr 18, 2022
9eec535
Merge branch 'master' into tippy-1-tooltip
timja May 1, 2022
eff05c8
Fix tooltip appearance for super wordy tooltips
janfaracik May 2, 2022
e409234
Replace all br in tooltip not just first
timja May 2, 2022
dfec00f
Merge branch 'master' into tippy-1-tooltip
timja May 7, 2022
7b6caca
HtmlUnit doesn't support replaceAll -.-
timja May 7, 2022
e15f08c
Don't apply tooltip and html-tooltip together, remove interactive
timja May 7, 2022
65c7379
Merge branch 'master' into tippy-1-tooltip
janfaracik May 13, 2022
75ac99d
Merge branch 'master' into tippy-1-tooltip
janfaracik May 23, 2022
b1ce8f6
Merge branch 'master' into tippy-1-tooltip
daniel-beck May 31, 2022
07c0005
Merge branch 'master' into tippy-1-tooltip
janfaracik May 31, 2022
50100c3
Merge branch 'master' into tippy-1-tooltip
janfaracik Jun 2, 2022
dcf52ce
Merge branch 'master' into tippy-1-tooltip
timja Jun 22, 2022
9b006ba
Merge branch 'master' into tippy-1-tooltip
timja Jun 23, 2022
9344488
html-tooltip support for icons
timja Jun 23, 2022
2dd9d9f
Escape html-tooltip
timja Jun 26, 2022
61f6553
Use data attribute as otherwise it invalidates html
timja Jun 26, 2022
66acbc1
Merge branch 'tippy-1-tooltip' of github.com:janfaracik/jenkins into …
timja Jun 26, 2022
1eef1ce
Revert unintended change
timja Jun 27, 2022
edda0e7
Tweak docs
timja Jun 27, 2022
cdad587
Merge branch 'master' into tippy-1-tooltip
janfaracik Jul 7, 2022
b61dd7e
Update yarn.lock
janfaracik Jul 7, 2022
8be0610
Merge branch 'master' into tippy-1-tooltip
janfaracik Jul 7, 2022
cc4a090
Merge branch 'master' into tippy-1-tooltip
janfaracik Jul 24, 2022
fd121b2
Lint, fix test
janfaracik Jul 24, 2022
462601e
Merge branch 'master' into tippy-1-tooltip
janfaracik Jul 24, 2022
683512c
Merge remote-tracking branch 'jenkinsci/master' into tippy-1-tooltip
daniel-beck Aug 12, 2022
0bcf83d
Merge remote-tracking branch 'origin/master' into tippy-1-tooltip
basil Aug 12, 2022
8ea8741
Merge remote-tracking branch 'origin/master' into tippy-1-tooltip
basil Aug 22, 2022
893d3c1
Merge remote-tracking branch 'origin/master' into tippy-1-tooltip
basil Aug 25, 2022
6f9055e
yarn lint
basil Aug 26, 2022
c51d1a6
Merge branch 'master' into tippy-1-tooltip
basil Aug 26, 2022
b52e3aa
Merge branch 'master' into tippy-1-tooltip
janfaracik Aug 29, 2022
1c779d3
Merge branch 'tippy-1-tooltip' of https://github.com/janfaracik/jenki…
janfaracik Aug 29, 2022
27fc179
Merge branch 'master' into tippy-1-tooltip
janfaracik Aug 29, 2022
0ac63d4
Update core/src/main/resources/lib/layout/icon.jelly
janfaracik Aug 29, 2022
87345f1
Small progress
janfaracik Aug 29, 2022
d0f7d21
Merge branch 'master' into tippy-1-tooltip
janfaracik Aug 29, 2022
5adcee3
Merge branch 'master' into tippy-1-tooltip
janfaracik Aug 30, 2022
5d0cded
Use shim
janfaracik Aug 30, 2022
e2cbf27
Apply suggestions from code review
janfaracik Aug 30, 2022
adaddab
Tidy up code
janfaracik Aug 30, 2022
db3c974
Merge remote-tracking branch 'jenkinsci/master' into tippy-1-tooltip
daniel-beck Aug 31, 2022
afa9ccc
Merge branch 'master' into tippy-1-tooltip
daniel-beck Sep 2, 2022
c166c7c
Merge branch 'master' into tippy-1-tooltip
timja Sep 23, 2022
f728b6c
Move hoverNotification setter to bottom of init
janfaracik Sep 23, 2022
76062ba
Update Security2776Test.java
janfaracik Sep 23, 2022
e009f9f
Update selector for tooltip
janfaracik Sep 26, 2022
e472a5d
Merge branch 'master' into tippy-1-tooltip
janfaracik Sep 27, 2022
816d168
Use Tippy show method
janfaracik Sep 27, 2022
94cbd3b
Change variable for tooltip backplates, alter table border radius
janfaracik Sep 27, 2022
28347fd
Hopefully fix tests
janfaracik Sep 28, 2022
a52f3ea
Refactor test
janfaracik Sep 29, 2022
80c80bd
Update Security2776Test.java
janfaracik Sep 29, 2022
185d41c
Update Security2776Test.java
janfaracik Sep 30, 2022
d0b645c
Merge branch 'master' into tippy-1-tooltip
janfaracik Sep 30, 2022
c790ca3
Update yarn.lock
janfaracik Sep 30, 2022
8d295a1
Restore tests
janfaracik Sep 30, 2022
7332213
Trigger Build
janfaracik Sep 30, 2022
3c6a349
Merge branch 'master' into tippy-1-tooltip
timja Oct 1, 2022
562e205
Merge branch 'master' into tippy-1-tooltip
janfaracik Oct 5, 2022
d21a32c
Fix test
janfaracik Oct 5, 2022
adc397a
Merge branch 'master' into tippy-1-tooltip
janfaracik Oct 5, 2022
9d84fc0
Update tooltips.less
janfaracik Oct 5, 2022
f735286
Merge branch 'tippy-1-tooltip' of https://github.com/janfaracik/jenki…
janfaracik Oct 5, 2022
374adad
Update prototype.js
janfaracik Oct 5, 2022
ad04817
Add support for interactive tooltips
janfaracik Oct 6, 2022
7e7dd24
Merge branch 'master' into tippy-1-tooltip
janfaracik Oct 9, 2022
573b6c4
Merge branch 'master' into tippy-1-tooltip
timja Oct 17, 2022
08e63ab
Merge branch 'master' into tippy-1-tooltip
janfaracik Oct 19, 2022
49bda1b
Update buildHealth.jelly
janfaracik Oct 19, 2022
0801d1f
Merge branch 'master' into tippy-1-tooltip
janfaracik Oct 19, 2022
cdf830d
Merge branch 'master' into tippy-1-tooltip
timja Nov 3, 2022
07c0d94
Merge branch 'master' into tippy-1-tooltip
timja Nov 13, 2022
a1e2f9a
Update core/src/main/java/org/jenkins/ui/icon/IconSet.java
timja Nov 14, 2022
d31a25a
Remove need for double escaping
timja Nov 14, 2022
084d703
Fix some of the tests
timja Nov 14, 2022
c1e1bb6
More fixes
timja Nov 20, 2022
c6735ca
Remove double escaping
timja Nov 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions core/src/main/java/org/jenkins/ui/icon/IconSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private static String prependTitleIfRequired(String icon, String title) {

// for Jelly
@Restricted(NoExternalUse.class)
public static String getSymbol(String name, String title, String tooltip, String classes, String pluginName, String id) {
public static String getSymbol(String name, String title, String tooltip, String htmlTooltip, String classes, String pluginName, String id) {
String translatedName = cleanName(name);

String identifier = Util.fixEmpty(pluginName) == null ? "core" : pluginName;
Expand All @@ -95,10 +95,14 @@ public static String getSymbol(String name, String title, String tooltip, String
String symbol = symbolsForLookup.get(translatedName);
symbol = symbol.replaceAll("(class=\").*?(\")", "$1$2");
symbol = symbol.replaceAll("(tooltip=\").*?(\")", "");
symbol = symbol.replaceAll("(data-html-tooltip=\").*?(\")", "");
symbol = symbol.replaceAll("(id=\").*?(\")", "");
if (!tooltip.isEmpty()) {
if (!tooltip.isEmpty() && htmlTooltip.isEmpty()) {
symbol = symbol.replaceAll("<svg", "<svg tooltip=\"" + Functions.htmlAttributeEscape(tooltip) + "\"");
}
if (!htmlTooltip.isEmpty()) {
symbol = symbol.replaceAll("<svg", "<svg data-html-tooltip=\"" + Functions.htmlAttributeEscape(htmlTooltip) + "\"");
}
if (!id.isEmpty()) {
symbol = symbol.replaceAll("<svg", "<svg id=\"" + Functions.htmlAttributeEscape(id) + "\"");
}
Expand All @@ -124,10 +128,14 @@ public static String getSymbol(String name, String title, String tooltip, String
symbol = symbol.replaceAll("(<title>).*(</title>)", "$1$2");
symbol = symbol.replaceAll("(class=\").*?(\")", "$1$2");
symbol = symbol.replaceAll("(tooltip=\").*?(\")", "$1$2");
symbol = symbol.replaceAll("(data-html-tooltip=\").*?(\")", "$1$2");
symbol = symbol.replaceAll("(id=\").*?(\")", "");
if (!tooltip.isEmpty()) {
if (!tooltip.isEmpty() && htmlTooltip.isEmpty()) {
symbol = symbol.replaceAll("<svg", "<svg tooltip=\"" + Functions.htmlAttributeEscape(tooltip) + "\"");
}
if (!htmlTooltip.isEmpty()) {
symbol = symbol.replaceAll("<svg", "<svg data-html-tooltip=\"" + Functions.htmlAttributeEscape(htmlTooltip) + "\"");
}
if (!id.isEmpty()) {
symbol = symbol.replaceAll("<svg", "<svg id=\"" + Functions.htmlAttributeEscape(id) + "\"");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<l:icon class="icon-lock icon-sm" tooltip="${%Keep this build forever}:&lt;br/&gt;${h.xmlEscape(build.whyKeepLog)}" xmlns:l="/lib/layout"/>
<l:icon class="icon-lock icon-sm" tooltip="${%Keep this build forever}:\n${build.whyKeepLog}" xmlns:l="/lib/layout"/>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ THE SOFTWARE.
<?jelly escape-by-default='true'?>
<j:if xmlns:j="jelly:core" xmlns:l="/lib/layout" test="${it.isTagged()}">
<a href="${rootURL}/${it.run.url}tagBuild/">
<l:icon class="icon-save icon-sm" tooltip="${h.escape(it.tooltip)}"/>
<l:icon class="icon-save icon-sm" tooltip="${it.tooltip}"/>
</a>
</j:if>
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ THE SOFTWARE.
</j:otherwise>
</j:choose>
<j:set var="isQueued" value="${app.queue.contains(job)}"/>
<a id="${id}" tooltip="${h.htmlAttributeEscape(title)}" class="jenkins-table__button jenkins-!-build-color" href="${href}">
<a id="${id}" tooltip="${title}" class="jenkins-table__button jenkins-!-build-color" href="${href}">
<span class="${isQueued ? 'pulse-animation': ''}">
<l:icon src="symbol-play" />
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ THE SOFTWARE.
<td class="build-row-cell">
<div class="pane build-name">
<div class="build-icon">
<a class="build-status-link" href="${link}console"><l:icon alt="${build.iconColor.description} &gt; ${%Console Output}" class="${build.buildStatusIconClassName} icon-sm" tooltip="${build.iconColor.description} &gt; ${%Console Output}"/></a>
<a class="build-status-link" href="${link}console" tooltip="${build.iconColor.description} > ${%Console Output}">
<l:icon class="${build.buildStatusIconClassName} icon-sm" />
</a>
</div>
<a class="model-link inside build-link display-name" update-parent-class=".build-row" href="${link}">${build.displayName}</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ THE SOFTWARE.
</j:choose>
<j:if test="${!item.params.isEmpty()}">
<div style="float:right;margin-right:10px;">
<a href="#" tooltip="Build Parameters:${h.escape(item.params)}"><l:icon class="icon-notepad icon-sm" /></a>
<a href="#" tooltip="Build Parameters:${item.params}"><l:icon class="icon-notepad icon-sm" /></a>
</div>
</j:if>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ THE SOFTWARE.
</st:attribute>
</st:documentation>
<st:adjunct includes="lib.form.repeatable.repeatable"/>
<button tooltip="${h.xmlEscape(attrs.value ?: '%Delete')}" class="repeatable-delete danger" type="button">
<button tooltip="${attrs.value ?: '%Delete'}" class="repeatable-delete danger" type="button">
<l:icon src="symbol-close" />
</button>
</j:jelly>
56 changes: 29 additions & 27 deletions core/src/main/resources/lib/hudson/buildHealth.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,40 @@ THE SOFTWARE.
<x:element name="${useTdElement!=null?'td':'div'}">
<x:attribute name="data">${buildHealth.score}</x:attribute>
<x:attribute name="class">jenkins-table__cell--tight jenkins-table__icon healthReport</x:attribute>
<j:if test="${!empty(healthReports)}">
<x:attribute name="data-html-tooltip">
<div class="jenkins-tooltip--table-wrapper">
<table class="jenkins-table">
<thead>
<tr>
<th class="jenkins-!-padding-left-0" align="center">W</th>
<th align="left">${%Description}</th>
<th align="right">%</th>
</tr>
</thead>
<tbody>
<j:forEach var="rpt" items="${healthReports}">
<tr>
<td align="left" class="jenkins-table__cell--tight jenkins-table__icon">
<div class="jenkins-table__cell__button-wrapper">
<l:icon src="symbol-weather-${buildHealth.iconClassName}" />
</div>
</td>
<td align="left">${rpt.localizableDescription}</td>
<td align="right">${rpt.score}</td>
</tr>
</j:forEach>
</tbody>
</table>
</div>
</x:attribute>
</j:if>
<j:if test="${buildHealth!=null}">
<div class="jenkins-table__cell__button-wrapper">
<j:choose>
<j:when test="${!empty(healthReports)}">
<a class="build-health-link jenkins-table__button" href="${empty(link)?'#':link}" style="${attrs.style}">
<l:icon src="symbol-weather-${buildHealth.iconClassName}" />
<l:icon src="symbol-weather-${buildHealth.iconClassName}" />
</a>
</j:when>
<j:otherwise>
Expand All @@ -52,31 +80,5 @@ THE SOFTWARE.
</j:choose>
</div>
</j:if>
<j:if test="${!empty(healthReports)}">
<div class="jenkins-tooltip healthReportDetails">
<table class="jenkins-table">
<thead>
<tr>
<th class="jenkins-!-padding-left-0" align="center">W</th>
<th align="left">${%Description}</th>
<th align="right">%</th>
</tr>
</thead>
<tbody>
<j:forEach var="rpt" items="${healthReports}">
<tr>
<td align="left" class="jenkins-table__cell--tight jenkins-table__icon">
<div class="jenkins-table__cell__button-wrapper">
<l:icon src="symbol-weather-${buildHealth.iconClassName}" />
</div>
</td>
<td align="left">${rpt.localizableDescription}</td>
<td align="right">${rpt.score}</td>
</tr>
</j:forEach>
</tbody>
</table>
</div>
</j:if>
</x:element>
</j:jelly>
2 changes: 1 addition & 1 deletion core/src/main/resources/lib/hudson/queue.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ THE SOFTWARE.
<j:set var="stuck" value="${item.isStuck()}"/>
<j:choose>
<j:when test="${h.hasPermission(item.task,item.task.READ)}">
<a href="${rootURL}/${item.task.url}" class="model-link inside tl-tr" tooltip="${h.escape(item.causesDescription)}${h.escape(item.why)}${h.escape(item.params)}&lt;br&gt;${%WaitingFor(item.inQueueForString)}">
<a href="${rootURL}/${item.task.url}" class="model-link inside tl-tr" tooltip="${item.causesDescription} ${item.why} ${item.params} \n ${%WaitingFor(item.inQueueForString)}">
<l:breakable value="${item.task.fullDisplayName}"/>
</a>
<!-- TODO include estimated number as in BuildHistoryWidget/entries.jelly if possible -->
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/lib/layout/helpIcon.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<j:if test="${attrs.iconSize != null}">
<j:set var="iconSize" value="icon-${iconSize}"/>
</j:if>
<l:icon tooltip="${h.htmlAttributeEscape(tooltip)}"
<l:icon tooltip="${tooltip}"
class="${class} ${iconSize}"
src="symbol-help-circle" />
</j:jelly>
12 changes: 7 additions & 5 deletions core/src/main/resources/lib/layout/icon.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ THE SOFTWARE.
</st:attribute>

<st:attribute name="onclick" deprecated="true">onclick handler. Deprecated; assign an ID and look up the element that way to attach event handlers.</st:attribute>
<st:attribute name="title" deprecated="true">title, deprecated use tooltip instead, but beware of its support for HTML</st:attribute>
<st:attribute name="title" deprecated="true">title, deprecated use tooltip instead, or htmlTooltip if you intend to pass HTML.</st:attribute>
<st:attribute name="style">style</st:attribute>
<st:attribute name="tooltip">
tooltip (supports HTML for PNG and symbol icons).
Make sure to call h.htmlAttributeEscape on all user-specified parts of the value to prevent cross-site scripting.
Icons based on classic (non-symbol) SVG do not support HTML tooltips due to how SECURITY-1955 was fixed in Jenkins 2.252 and 2.235.4, but since such icons can be upgraded to symbols, it is important to still escape user-specified parts of the text (resulting in double escaping while the icon is based on classic SVG).</st:attribute>
Adds a tooltip to the icon, ignores HTML except 'br' tags (but '\n' should be preferred for line breaks).</st:attribute>
<st:attribute name="htmlTooltip">
Tooltip but with HTML support. Make sure to call h.htmlAttributeEscape on all user-specified parts of the value to prevent cross-site scripting.
Use 'tooltip' if you don't need to pass HTML.</st:attribute>
<st:attribute name="alt">alt, adds invisible text suitable for screen-readers for symbols, sets the alt attribute for normal images</st:attribute>
</st:documentation>

Expand All @@ -71,6 +72,7 @@ THE SOFTWARE.
<j:arg value="${iconSrc.substring(7)}" />
<j:arg value="${alt ?: ''}" />
<j:arg value="${attrs.tooltip ?: ''}" />
<j:arg value="${attrs.htmlTooltip ?: ''}" />
<j:arg value="${attrs.class ?: iconMetadata.classSpec ?: ''}" />
<j:arg value="${h.extractPluginNameFromIconSrc(iconSrc)}" />
<j:arg value="${attrs.id ?: ''}" />
Expand All @@ -96,7 +98,7 @@ THE SOFTWARE.

<j:otherwise>
<img class="${attrs.class}" src="${iconSrc}" style="${imgStyle}" title="${attrs.title}" height="${attrs.height}"
alt="${attrs.alt}" width="${attrs.width}" onclick="${attrs.onclick}" tooltip="${attrs.tooltip}" id="${attrs.id}" />
alt="${attrs.alt}" width="${attrs.width}" onclick="${attrs.onclick}" tooltip="${attrs.tooltip}" data-html-tooltip="${attrs.htmlTooltip}" id="${attrs.id}" />
</j:otherwise>
</j:choose>
</j:otherwise>
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/lib/layout/svgIcon.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
style="${attrs.style}"
onclick="${attrs.onclick}"
id="${attrs.id}"
tooltip="${attrs.tooltip != null ? h.xmlEscape(attrs.tooltip) : null}">
tooltip="${attrs.tooltip != null ? attrs.tooltip : null}">

<j:choose>
<j:when test="${attrs.href != null}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public class IconSetJenkins68805Test {
@Issue("JENKINS-68805")
void getSymbol_notSettingTooltipDoesntAddTooltipAttribute_evenWithAmpersand() {
// cache a symbol with tooltip containing ampersand:
String symbolWithTooltip = IconSet.getSymbol("download", "Title", "With&Ampersand", "class1 class2", "", "id");
String symbolWithTooltip = IconSet.getSymbol("download", "Title", "With&Ampersand", "", "class1 class2", "", "id");
assertThat(symbolWithTooltip, containsString("tooltip"));
assertThat(symbolWithTooltip, containsString("With&"));

// Same symbol, no tooltip
String symbolWithoutTooltip = IconSet.getSymbol("download", "Title", "", "class1 class2", "", "id");
String symbolWithoutTooltip = IconSet.getSymbol("download", "Title", "", "", "class1 class2", "", "id");

assertThat(symbolWithoutTooltip, not(containsString("tooltip")));
}
Expand Down
12 changes: 6 additions & 6 deletions core/src/test/java/org/jenkins/ui/icon/IconSetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void testIconSetSize() {

@Test
void getSymbol() {
String symbol = IconSet.getSymbol("download", "Title", "Tooltip", "class1 class2", "", "id");
String symbol = IconSet.getSymbol("download", "Title", "Tooltip", "", "class1 class2", "", "id");

assertThat(symbol, containsString("<span class=\"jenkins-visually-hidden\">Title</span>"));
assertThat(symbol, containsString("tooltip=\"Tooltip\""));
Expand All @@ -31,8 +31,8 @@ void getSymbol() {

@Test
void getSymbol_cachedSymbolDoesntReturnAttributes() {
IconSet.getSymbol("download", "Title", "Tooltip", "class1 class2", "", "id");
String symbol = IconSet.getSymbol("download", "", "", "", "", "");
IconSet.getSymbol("download", "Title", "Tooltip", "", "class1 class2", "", "id");
String symbol = IconSet.getSymbol("download", "", "", "", "", "", "");

assertThat(symbol, not(containsString("<span class=\"jenkins-visually-hidden\">Title</span>")));
assertThat(symbol, not(containsString("tooltip=\"Tooltip\"")));
Expand All @@ -43,8 +43,8 @@ void getSymbol_cachedSymbolDoesntReturnAttributes() {

@Test
void getSymbol_cachedSymbolAllowsSettingAllAttributes() {
IconSet.getSymbol("download", "Title", "Tooltip", "class1 class2", "", "id");
String symbol = IconSet.getSymbol("download", "Title2", "Tooltip2", "class3 class4", "", "id2");
IconSet.getSymbol("download", "Title", "Tooltip", "", "class1 class2", "", "id");
String symbol = IconSet.getSymbol("download", "Title2", "Tooltip2", "", "class3 class4", "", "id2");

assertThat(symbol, not(containsString("<span class=\"jenkins-visually-hidden\">Title</span>")));
assertThat(symbol, not(containsString("tooltip=\"Tooltip\"")));
Expand All @@ -62,7 +62,7 @@ void getSymbol_cachedSymbolAllowsSettingAllAttributes() {
*/
@Test
void getSymbol_notSettingTooltipDoesntAddTooltipAttribute() {
String symbol = IconSet.getSymbol("download", "Title", "", "class1 class2", "", "id");
String symbol = IconSet.getSymbol("download", "Title", "", "", "class1 class2", "", "id");

assertThat(symbol, not(containsString("tooltip")));
}
Expand Down
15 changes: 5 additions & 10 deletions test/src/test/java/hudson/model/QueueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,10 @@

import com.gargoylesoftware.htmlunit.HttpMethod;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.ScriptResult;
import com.gargoylesoftware.htmlunit.WebRequest;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.DomNodeList;
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlFileInput;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlFormUtil;
Expand Down Expand Up @@ -1272,14 +1270,11 @@ private String buildAndExtractTooltipAttribute() throws Exception {

HtmlPage page = wc.goTo("");

DomElement buildQueue = page.getElementById("buildQueue");
DomNodeList<HtmlElement> anchors = buildQueue.getElementsByTagName("a");
HtmlAnchor anchorWithTooltip = (HtmlAnchor) anchors.stream()
.filter(a -> a.getAttribute("tooltip") != null && !a.getAttribute("tooltip").isEmpty())
.findFirst().orElseThrow(IllegalStateException::new);
page.executeJavaScript("document.querySelector('#buildQueue a[tooltip]:not([tooltip=\"\"])')._tippy.show()");
wc.waitForBackgroundJavaScript(1000);
ScriptResult result = page.executeJavaScript("document.querySelector('.tippy-content').innerHTML;");

String tooltip = anchorWithTooltip.getAttribute("tooltip");
return tooltip;
return result.getJavaScriptResult().toString();
}

public static class BrokenAffinityKeyProject extends Project<BrokenAffinityKeyProject, BrokenAffinityKeyBuild> implements TopLevelItem {
Expand Down
4 changes: 2 additions & 2 deletions test/src/test/java/hudson/model/RunTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ private void ensureXssIsPrevented(FreeStyleProject upProject, String validationP
HtmlPage htmlPage = wc.goTo(upProject.getUrl());

// trigger the tooltip display
htmlPage.executeJavaScript("document.querySelector('#buildHistory table .build-badge img').dispatchEvent(new Event('mouseover'));");
htmlPage.executeJavaScript("document.querySelector('#buildHistory table .build-badge img')._tippy.show()");
wc.waitForBackgroundJavaScript(500);
ScriptResult result = htmlPage.executeJavaScript("document.querySelector('#tt').innerHTML;");
ScriptResult result = htmlPage.executeJavaScript("document.querySelector('.tippy-content').innerHTML;");
Object jsResult = result.getJavaScriptResult();
assertThat(jsResult, instanceOf(String.class));
String jsResultString = (String) jsResult;
Expand Down
18 changes: 0 additions & 18 deletions test/src/test/java/hudson/scm/AbstractScmTagActionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@

package hudson.scm;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertEquals;

import com.gargoylesoftware.htmlunit.html.DomElement;
Expand All @@ -45,7 +41,6 @@
import java.io.File;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;

public class AbstractScmTagActionTest {
Expand All @@ -66,19 +61,6 @@ public void regularTextDisplayedCorrectly() throws Exception {
assertEquals(tagToKeep, tooltip);
}

@Test
@Issue("SECURITY-1537")
public void preventXssInTagAction() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
p.setScm(new FakeSCM("<img src='x' onerror=alert(123)>XSS"));

j.buildAndAssertSuccess(p);

String tooltip = buildAndExtractTooltipAttribute(p);
assertThat(tooltip, not(containsString("<")));
assertThat(tooltip, startsWith("&lt;"));
}

private String buildAndExtractTooltipAttribute(FreeStyleProject p) throws Exception {
JenkinsRule.WebClient wc = j.createWebClient();

Expand Down
Loading