diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java index a48e110fb45..b09d495714b 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java @@ -177,12 +177,13 @@ public Map getDisplayValueMap() { if (StringUtils.isBlank(format)) { format = "#VALUE"; } + String sanitizedValue = childDatasetField.getDatasetFieldType().isSanitizeHtml() ? MarkupChecker.sanitizeBasicHTML(childDatasetField.getValue()) : childDatasetField.getValue(); if (!childDatasetField.getDatasetFieldType().isSanitizeHtml() && childDatasetField.getDatasetFieldType().isEscapeOutputText()){ sanitizedValue = MarkupChecker.stripAllTags(sanitizedValue); } //if a series of child values is comma delimited we want to strip off the final entry's comma - if (format.equals("#VALUE, ")) fixTrailingComma = true; + if (format.trim().equals("#VALUE,")) fixTrailingComma = true; // replace the special values in the format (note: we replace #VALUE last since we don't // want any issues if the value itself has #NAME in it) @@ -247,9 +248,17 @@ private Map removeLastComma(Map mapI keyVal = entry.getKey(); oldValue = entry.getValue(); } - + + String newValue = oldValue; + if (keyVal != null && oldValue != null && oldValue.length() >= 2) { - String newValue = oldValue.substring(0, oldValue.length() - 2); + //To take into account both versions of the tsv for display value + if (oldValue.endsWith(", ")) { + newValue = oldValue.substring(0, oldValue.length() - 2); + } else if (oldValue.endsWith(",")) { + newValue = oldValue.substring(0, oldValue.length() - 1); + } + mapIn.replace(keyVal, oldValue, newValue); }