Skip to content

Commit c98c258

Browse files
authored
Merge pull request #197 from bimberlabinternal/25.7_fb_htmldecoding
Manually decode form parameters
2 parents 8a4bd6c + 2f850c8 commit c98c258

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

GenotypeAssays/src/org/labkey/genotypeassays/GenotypeAssaysController.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.labkey.genotypeassays;
1818

19+
import org.apache.commons.text.StringEscapeUtils;
1920
import org.json.JSONArray;
2021
import org.labkey.api.action.ApiResponse;
2122
import org.labkey.api.action.ApiSimpleResponse;
@@ -37,6 +38,7 @@
3738
import org.springframework.validation.Errors;
3839
import org.springframework.web.servlet.ModelAndView;
3940

41+
import java.util.Arrays;
4042
import java.util.HashMap;
4143
import java.util.List;
4244
import java.util.Map;
@@ -130,7 +132,8 @@ public ApiResponse execute(CacheAnalysesForm form, BindException errors)
130132
return null;
131133
}
132134

133-
Pair<List<Integer>, List<Integer>> ret = GenotypeAssaysManager.get().cacheAnalyses(getViewContext(), protocol, form.getAlleleNames());
135+
String[] alleleNames = Arrays.stream(form.getAlleleNames()).map(StringEscapeUtils::unescapeHtml4).toArray(String[]::new);
136+
Pair<List<Integer>, List<Integer>> ret = GenotypeAssaysManager.get().cacheAnalyses(getViewContext(), protocol, alleleNames);
134137
resultProperties.put("runsCreated", ret.first);
135138
resultProperties.put("runsDeleted", ret.second);
136139
}

GenotypeAssays/src/org/labkey/genotypeassays/GenotypeAssaysManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import java.util.List;
6161
import java.util.Map;
6262
import java.util.Set;
63+
import java.util.concurrent.atomic.AtomicInteger;
6364

6465
public class GenotypeAssaysManager
6566
{
@@ -121,13 +122,15 @@ public Pair<List<Integer>, List<Integer>> cacheAnalyses(final ViewContext ctx, f
121122
final Map<Integer, List<Map<String, Object>>> rowHash = new HashMap<>();
122123
final Map<Integer, Set<Integer>> toDeleteByAnalysis = new HashMap<>();
123124

125+
AtomicInteger records = new AtomicInteger();
124126
TableSelector tsAlignments = new TableSelector(tableAlignments, cols.values(), new SimpleFilter(FieldKey.fromString("key"), Arrays.asList(pks), CompareType.IN), null);
125127
tsAlignments.forEach(new Selector.ForEachBlock<ResultSet>()
126128
{
127129
@Override
128130
public void exec(ResultSet object) throws SQLException
129131
{
130132
Results rs = new ResultsImpl(object, cols);
133+
records.getAndIncrement();
131134

132135
int analysisId = rs.getInt(FieldKey.fromString("analysis_id"));
133136
String lineages = rs.getString(FieldKey.fromString("lineages"));
@@ -167,6 +170,11 @@ public void exec(ResultSet object) throws SQLException
167170
}
168171
});
169172

173+
if (records.get() != pks.length)
174+
{
175+
throw new IllegalStateException("The number of records found did not match the number supplied. This indicates a problem with the import.");
176+
}
177+
170178
if (!rowHash.isEmpty())
171179
{
172180
processSet(SBT_LINEAGE_ASSAY_TYPE, rowHash, assayDataTable, u, ctx, toDeleteByAnalysis, ap, protocol, runsCreated);

0 commit comments

Comments
 (0)