Skip to content
Open
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
8 changes: 7 additions & 1 deletion api/src/org/labkey/api/data/MultiChoice.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public static class DisplayColumn extends DataColumn
public DisplayColumn(ColumnInfo col)
{
super(col, false);
setTextAlign("left"); // GitHub Issue 933: Left align MV cells in grids
}

@Override
Expand Down Expand Up @@ -219,7 +220,12 @@ protected Array(Stream<Object> str)
str.filter(Objects::nonNull)
.map(s -> StringUtils.trimToNull(s.toString()))
.filter(Objects::nonNull)
.forEach(setCaseSensitive::add);
.forEach(s ->
{
// GitHub Issue 942: Add error for duplicate values for MVTC fields
if (!setCaseSensitive.add(s))
throw new ConversionExceptionWithMessage("Duplicate value provided: " + s);
});
array = setCaseSensitive.toArray(new String[0]);
}

Expand Down
6 changes: 4 additions & 2 deletions api/src/org/labkey/api/query/QueryChangeListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ private static String getUpdatedFilterStrFromMVTC(String filterStr, String prefi
if (oldType.getPropertyType() != PropertyType.MULTI_CHOICE || newType.getPropertyType() == PropertyType.MULTI_CHOICE)
return filterStr;

String columnNameEncoded = PageFlowUtil.encodeURIComponent(QueryKey.encodePart(columnName));
// GitHub Issue 943: Converting between TC and MVTC results in bad saved views
// single quote should decode to match url filter
String columnNameEncoded = PageFlowUtil.encodeURIComponent(QueryKey.encodePart(columnName), true);

String colLower = columnNameEncoded.toLowerCase();
String sLower = filterStr.toLowerCase();
Expand Down Expand Up @@ -285,7 +287,7 @@ private static String getUpdatedMVTCFilterStr(String filterStr, String prefix, S
if (oldType.getPropertyType() == PropertyType.MULTI_CHOICE || newType.getPropertyType() != PropertyType.MULTI_CHOICE)
return filterStr;

String columnNameEncoded = PageFlowUtil.encodeURIComponent(QueryKey.encodePart(columnName));
String columnNameEncoded = PageFlowUtil.encodeURIComponent(QueryKey.encodePart(columnName), true);

String colLower = columnNameEncoded.toLowerCase();
String sLower = filterStr.toLowerCase();
Expand Down
8 changes: 8 additions & 0 deletions api/src/org/labkey/api/util/PageFlowUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,14 @@ public static String wafEncode(@Nullable String plain)
return encode(s, true);
}

public static @NotNull String encodeURIComponent(String s, boolean decodeSingleQuote)
{
String encoded = encodeURIComponent(s);
if (!decodeSingleQuote)
return encoded;
return Strings.CS.replace(encoded, "%27", "'");
}

/**
* Intended to be equivalent to JavaScript encodeURI().
*/
Expand Down
Loading