Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<%@ page import="org.labkey.api.data.Container" %>
<%@ page import="org.labkey.api.security.User" %>
<%@ page import="org.labkey.api.util.HtmlString" %>
<%@ page import="org.labkey.api.util.StringUtilsLabKey" %>
<%@ page import="org.labkey.api.view.ActionURL" %>
<%@ page import="org.labkey.api.view.HttpView" %>
<%@ page import="org.labkey.api.view.template.ClientDependencies" %>
Expand Down Expand Up @@ -194,7 +195,9 @@ for (AnnouncementModel a : bean.announcementModels)
<tr>
<td width="40%" align="left"><%
if (a.getResponseCount() > 0)
out.print(unsafe(" (" + a.getResponseCount() + (a.getResponseCount() == 1 ? "&nbsp;response)" : "&nbsp;responses)")));
{
%> (<%=h(StringUtilsLabKey.pluralize(a.getResponseCount(), "response"))%>)<%
}
%></td>
<td width="20%" align="center" class="message-creator"><%=AnnouncementManager.getUserDetailsLink(c, user, a.getCreatedBy(), bean.includeGroups, false)%></td>
<td width="40%" align="right" nowrap><%=formatDateTime(a.getCreated())%></td>
Expand Down
2 changes: 1 addition & 1 deletion announcements/src/org/labkey/announcements/rss.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<title><%=h(ann.getTitle())%></title>
<link><%=h(bean.url)%><%=ann.getRowId()%>&amp;_print=1</link>
<description><%=h(ann.getBody())%></description>
<pubDate><%=unsafe(ann.getCreated().toString())%></pubDate>
<pubDate><%=h(ann.getCreated())%></pubDate>
</item><%
}%>
</channel>
Expand Down
1 change: 1 addition & 0 deletions api/src/org/labkey/api/assay/AssayDataCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public String getButtonText()
/** @return the name for this AssayDataCollector. Needs to be unique within the set of data collectors for any given import attempt */
String getShortName();

// TODO: Should return HtmlString
String getDescription(ContextType context);

/** Map of original file name to file on disk */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
import org.labkey.api.query.ValidationException;
import org.labkey.api.security.User;
import org.labkey.api.security.permissions.AdminPermission;
import org.labkey.api.util.Pair;
import org.labkey.api.util.LinkBuilder.Link;
import org.labkey.api.util.ReentrantLockWithName;
import org.labkey.api.view.ActionURL;
import org.labkey.api.writer.ContainerUser;
Expand Down Expand Up @@ -266,7 +266,7 @@ public void addAdditionalQueryColumns(TableInfo table)
{
}

public Map<String, List<Pair<String, ActionURL>>> getAdditionalDetailInfo(TableInfo tableInfo, int issueId)
public Map<String, List<Link>> getAdditionalDetailInfo(TableInfo tableInfo, int issueId)
{
return null;
}
Expand Down
3 changes: 2 additions & 1 deletion api/src/org/labkey/api/study/Visit.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.labkey.api.study;

import org.apache.commons.lang3.StringUtils;
import org.labkey.api.util.SafeToRenderEnum;

import java.math.BigDecimal;

Expand Down Expand Up @@ -115,7 +116,7 @@ public String getSortColumns()
}
}

enum SequenceHandling
enum SequenceHandling implements SafeToRenderEnum
{
normal, // as determined by TimepointType
logUniqueByDate // append days since start of study in fractional part of sequencenum
Expand Down
9 changes: 9 additions & 0 deletions api/src/org/labkey/api/util/HtmlStringBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.labkey.api.util;

import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;

import java.util.regex.Pattern;
Expand Down Expand Up @@ -56,6 +57,14 @@ public static HtmlStringBuilder of(HasHtmlString hhs)
return new HtmlStringBuilder().append(hhs);
}

// Create a new HtmlStringBuilder initialized with an HtmlString repeated count times
public static HtmlStringBuilder repeat(HtmlString hs, int count)
{
HtmlStringBuilder builder = new HtmlStringBuilder();
builder._sb.append(StringUtils.repeat(hs.toString(), count));
return builder;
}

public HtmlStringBuilder append(String s)
{
_sb.append(h(s));
Expand Down
6 changes: 3 additions & 3 deletions assay/src/org/labkey/api/assay/nab/view/cutoffDilutions.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@
String modifier = "";
if (val == Double.NEGATIVE_INFINITY)
{
modifier = "&lt; ";
modifier = "< ";
val = summary.getMinDilution(assay.getRenderedCurveFitType());
}
else if (val == Double.POSITIVE_INFINITY)
{
modifier = "&gt; ";
modifier = "> ";
val = summary.getMaxDilution(assay.getRenderedCurveFitType());
}

Expand All @@ -141,7 +141,7 @@
else if (Math.abs(val) < 1)
shortDecFormat = new DecimalFormat("0.###");

out.print(unsafe(modifier));
out.print(h(modifier));
out.print(h(shortDecFormat.format(val)));
}
%>
Expand Down
2 changes: 1 addition & 1 deletion assay/src/org/labkey/api/assay/nab/view/runNotes.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
if (deleteAndInsertPerms)
{
%>
you must <a href="<%= unsafe(rerunURL.getLocalURIString()) %>">delete and re-import</a> the run.
you must <a href="<%=h(rerunURL)%>">delete and re-import</a> the run.
<%
}
else
Expand Down
2 changes: 1 addition & 1 deletion assay/src/org/labkey/assay/view/dataUpload.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
{ %>
<td><input value="<%= h(collector.getShortName()) %>" id="<%=makeHtmlId(collector.getShortName())%>" type="hidden" name="dataCollectorName" /></td>
<% } %>
<td><label for="<%=makeHtmlId(collector.getShortName())%>"><%= unsafe(collector.getDescription(bean)) %></label></td>
<td><label for="<%=makeHtmlId(collector.getShortName())%>"><%=h(collector.getDescription(bean))%></label></td>
Comment thread
labkey-adam marked this conversation as resolved.
Resolved
</tr>
<tr style="visibility: <%= unsafe(first ? "visible" : "collapse") %>;" id="collector-<%= h(collector.getShortName()) %>">
<td></td>
Expand Down
8 changes: 5 additions & 3 deletions audit/src/org/labkey/audit/SiteSettingsAuditDetailsModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.labkey.api.data.Container;
import org.labkey.api.security.User;
import org.labkey.api.util.DateUtil;
import org.labkey.api.util.HtmlString;

import java.util.Date;

Expand All @@ -31,19 +32,20 @@
public class SiteSettingsAuditDetailsModel
{
private final Container _c;
private final String _diff;
private final HtmlString _diff;
private final User _createdBy;
private final Date _created;

public SiteSettingsAuditDetailsModel(Container c, String diff, User createdBy, Date created)
{
_c = c;
_diff = StringUtils.isEmpty(diff) ? "<p>No details were recorded.</p>" : diff;
// Audit writers store the changes as HTML, encoding values as they build it
_diff = StringUtils.isEmpty(diff) ? HtmlString.unsafe("<p>No details were recorded.</p>") : HtmlString.unsafe(diff);
_createdBy = createdBy;
_created = created;
}

public String getDiff()
public HtmlString getDiff()
{
return _diff;
}
Expand Down
2 changes: 1 addition & 1 deletion audit/src/org/labkey/audit/siteSettingsAuditDetails.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
the site settings were modified in the following way:
<% } %>
</p>
<%=unsafe(model.getDiff())%>
<%=model.getDiff()%>
18 changes: 10 additions & 8 deletions core/src/org/labkey/core/admin/importFolder.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<%@ page import="org.labkey.core.admin.AdminController.ImportFolderForm" %>
<%@ page import="org.labkey.api.settings.OptionalFeatureService" %>
<%@ page import="org.labkey.api.util.DOM" %>
<%@ page import="org.labkey.api.util.HtmlString" %>
<%@ page import="org.labkey.api.util.HtmlStringBuilder" %>
<%@ page import="static org.labkey.api.util.DOM.SPAN" %>
<%@ page import="static org.labkey.api.util.DOM.Attribute.style" %>
<%@ taglib prefix="labkey" uri="http://www.labkey.org/taglib" %>
Expand Down Expand Up @@ -80,7 +82,7 @@
final String noun;
final String action;
final String mainDescription;
final String helpLinkTxt;
final HtmlString helpLinkTxt;

final String whatIsAFolderArchive = "A folder archive is a .folder.zip file or a collection of individual files that " +
"conforms to the LabKey folder archive conventions and formats. A folder archive can be created using the folder " +
Expand All @@ -93,8 +95,8 @@
mainDescription = "You can create and populate a new study by importing a folder archive. " + whatIsAFolderArchive +
"Using export and import, a study's contents can be moved from one server to another or a new study can be " +
"created using a standard template.";
helpLinkTxt = "For more information about exporting, importing, and reloading studies, see " +
helpLink("importExportStudy", "the study import/export/reload documentation") + ".";
helpLinkTxt = HtmlStringBuilder.of("For more information about exporting, importing, and reloading studies, see ")
.append(helpLink("importExportStudy", "the study import/export/reload documentation")).append(".").getHtmlString();
}
else if (requestOrigin.equals("Reload"))
{
Expand All @@ -103,8 +105,8 @@
mainDescription = "You can update an existing study with new settings and data by reloading a folder archive. " +
whatIsAFolderArchive + "Note: Reloading a folder archive will replace existing study data with the data in " +
"the archive.";
helpLinkTxt = "For more information about exporting, importing, and reloading studies, see " +
helpLink("importExportStudy", "the study import/export/reload documentation") + ".";
helpLinkTxt = HtmlStringBuilder.of("For more information about exporting, importing, and reloading studies, see ")
.append(helpLink("importExportStudy", "the study import/export/reload documentation")).append(".").getHtmlString();
}
else
{
Expand All @@ -114,8 +116,8 @@
whatIsAFolderArchive + "Using export and import, a folder's contents can be moved from one server to another " +
"or a new folder can be created using a standard template. You can also populate a new folder from a template " +
"folder on the current server using the \"Create Folder From Template\" option on the folder creation page.";
helpLinkTxt = "For more information about exporting and importing folders, see " +
helpLink("importExportFolder", "the folder export/import documentation") + ".";
helpLinkTxt = HtmlStringBuilder.of("For more information about exporting and importing folders, see ")
.append(helpLink("importExportFolder", "the folder export/import documentation")).append(".").getHtmlString();
}
%>
<style type="text/css">
Expand All @@ -132,7 +134,7 @@
<td>
<%=h(mainDescription)%>
<br/><br/>
<%=unsafe(helpLinkTxt)%>
<%=helpLinkTxt%>
</td>
</tr>
<tr>
Expand Down
3 changes: 1 addition & 2 deletions core/src/org/labkey/core/admin/lookAndFeelProperties.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,7 @@

function confirmReset()
{
// Although not clearly documented, confirm() appears to encode the message
if (confirm('Are you sure you want to reset <%=unsafe(clearMessage)%>?'))
if (confirm(<%=q("Are you sure you want to reset " + clearMessage + "?")%>))
{
_form.setClean();
LABKEY.Utils.postToAction(<%=q(new AdminUrlsImpl().getResetLookAndFeelPropertiesURL(c))%>);
Expand Down
14 changes: 6 additions & 8 deletions core/src/org/labkey/core/admin/renameFolder.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<%@ page import="org.labkey.api.admin.AdminUrls"%>
<%@ page import="org.labkey.api.data.Container" %>
<%@ page import="org.labkey.api.data.ContainerManager" %>
<%@ page import="org.labkey.api.util.HtmlString" %>
<%@ page import="org.labkey.api.view.HttpView" %>
<%@ page import="org.labkey.api.view.JspView" %>
<%@ page import="org.labkey.api.view.template.ClientDependencies" %>
Expand All @@ -40,9 +41,6 @@
String name = form.getName();
String title = form.getTitle();

String disabled = c.isTitleFieldSet() ? "" : "disabled";
String checked = !c.isTitleFieldSet() ? "checked" : "unchecked";

if (null == name)
{
name = c.getName();
Expand All @@ -54,7 +52,7 @@
}


String containerType = (c.isProject() ? "Project" : "Folder");
HtmlString containerType = HtmlString.of(c.isProject() ? "Project" : "Folder");

// 16221
if (ContainerManager.isRenameable(c))
Expand Down Expand Up @@ -100,17 +98,17 @@
<%=formatMissedErrors("form")%>
<ul class="name-setings-form">
<li>
<label for="name"><%= unsafe(containerType)%> Name</label>
<label for="name"><%=containerType%> Name</label>
<input type="text" id="name" name="name" value="<%=h(name)%>">
</li>
<li>
<label for="title">
<%= unsafe(containerType)%> Title
<%=containerType%> Title
<span class="change-title-cb">
<input type="checkbox" id="titleSameAsName" name="titleSameAsName" <%=h(checked)%>>same as name
<input type="checkbox" id="titleSameAsName" name="titleSameAsName"<%=checked(!c.isTitleFieldSet())%>>same as name
</span>
</label>
<input type="text" id="title" name="title" <%=h(disabled)%> value="<%=h(title)%>">
<input type="text" id="title" name="title"<%=disabled(!c.isTitleFieldSet())%> value="<%=h(title)%>">
</li>
<li>
<label for="addAlias">Options</label>
Expand Down
3 changes: 1 addition & 2 deletions core/src/org/labkey/core/admin/systemMaintenance.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@
}
else
{
String checkboxDisabled = hasAdminOpsPerms ? "" : "disabled";
%><tr><td><input name="enable" <%=unsafe(checkboxDisabled)%> value="<%=h(task.getName())%>" type="checkbox"<%=checked(!disabled.contains(task.getName()))%>/><%=description%></td></tr><%
%><tr><td><input name="enable"<%=disabled(!hasAdminOpsPerms)%> value="<%=h(task.getName())%>" type="checkbox"<%=checked(!disabled.contains(task.getName()))%>/><%=description%></td></tr><%
}
}
%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
<td><input <%=h(canChangeFileSettings && hasAdminOpsPerm ? "" : " disabled ")%>
type="radio" name="fileRootOption" id="optionProjectSpecified" value="<%=FileRootProp.folderOverride%>"
<%=checked(FileRootProp.folderOverride.name().equals(currentOption))%>>
Use a <%=unsafe(c.getContainerNoun())%>-level file root
Use a <%=h(c.getContainerNoun())%>-level file root
<labkey:input type="text" id="folderRootPath" name="folderRootPath" size="64" onChange="onRootChange()" value="<%=h(bean.getFolderRootPath())%>" /></td>
<% addHandler("optionProjectSpecified", "click", "return updateSelection(" + !FileRootProp.folderOverride.name().equals(currentOption) + ");"); %>
</tr>
Expand Down
20 changes: 10 additions & 10 deletions core/src/org/labkey/core/security/GroupView.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@

package org.labkey.core.security;

import org.apache.commons.lang3.StringUtils;
import org.labkey.api.security.Group;
import org.labkey.api.security.UserPrincipal;
import org.labkey.api.util.HtmlString;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.api.util.HtmlStringBuilder;
import org.labkey.api.view.JspView;
import org.springframework.validation.BindException;

Expand Down Expand Up @@ -53,23 +52,24 @@ public static class GroupBean
public boolean isSystemGroup;
public Map<UserPrincipal, List<UserPrincipal>> redundantMembers;

public String displayRedundancyReasonHTML(UserPrincipal principal)
public HtmlString displayRedundancyReasonHTML(UserPrincipal principal)
{
StringBuilder sb = new StringBuilder();
HtmlStringBuilder sb = HtmlStringBuilder.of();
if (redundantMembers.containsKey(principal))
{
List<UserPrincipal> path = redundantMembers.get(principal);
sb.append("This member can be removed because:<BR/>");
sb.append("This member can be removed because:").append(HtmlString.BR);
for (int i = path.size()-1; i > 0; i--)
{
sb.append(StringUtils.repeat("&nbsp;&nbsp;&nbsp;", path.size() - i - 1));
sb.append(i == path.size() - 1 ? PageFlowUtil.filter(path.get(i)) : "Which");
for (int j = 0; j < 3 * (path.size() - i - 1); j++)
sb.append(HtmlString.NBSP);
sb.append(i == path.size() - 1 ? path.get(i).toString() : "Which");
sb.append(" is a member of ");
sb.append("<strong>").append(PageFlowUtil.filter(path.get(i-1))).append("</strong>");
sb.append("<BR/>");
sb.startTag("strong").append(path.get(i-1).toString()).endTag("strong");
sb.append(HtmlString.BR);
}
}
return sb.toString();
return sb.getHtmlString();
}
}
}
2 changes: 1 addition & 1 deletion core/src/org/labkey/core/security/group.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ else

if (bean.redundantMembers.containsKey(member))
{
%><a data-qtitle="Redundant Member" data-qtip="<%=unsafe(bean.displayRedundancyReasonHTML(member))%>">*</a><%
%><a data-qtitle="Redundant Member" data-qtip="<%=h(bean.displayRedundancyReasonHTML(member))%>">*</a><%
}
%>
&nbsp;&nbsp;</td>
Expand Down
13 changes: 8 additions & 5 deletions core/src/org/labkey/core/user/limitActiveUsers.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<%@ page import="org.labkey.core.user.LimitActiveUsersSettings" %>
<%@ page import="org.labkey.core.user.UserController.LimitActiveUsersAction" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.stream.Collectors" %>
<%@ page import="static org.labkey.core.user.LimitActiveUsersSettings.StartupProperties.*" %>
<%@ page extends="org.labkey.api.jsp.JspBase" %>
<%@ taglib prefix="labkey" uri="http://www.labkey.org/taglib" %>
Expand Down Expand Up @@ -93,9 +92,13 @@ The supported properties and their current values are listed in the table below.
<table class="labkey-data-region-legacy labkey-show-borders">
<tr class="labkey-frame"><th>Property</th><th>Current Value</th></tr>

<%=unsafe(
props.entrySet().stream()
.map(e -> "<tr valign=top class=\"labkey-row\"><td>" + h(e.getKey()) + "</td><td>" + h(e.getValue()) + "</td></tr>\n")
.collect(Collectors.joining()))%>
<%
for (Map.Entry<String, Integer> e : props.entrySet())
{
%>
<tr valign=top class="labkey-row"><td><%=h(e.getKey())%></td><td><%=h(e.getValue())%></td></tr>
<%
}
%>

</table>
Loading