diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java b/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java index a0449efb..41ba7cdf 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java @@ -888,4 +888,23 @@ public final class Utils { * ((descending) ? -1 : 1); } + public static String toFileName(final String name) { + if (name == null) { + return null; + } + + return name + .replace("ä", "ae") + .replace("ö", "oe") + .replace("ü", "ue") + .replace("Ä", "Ae") + .replace("Ö", "Oe") + .replace("Ü", "Ue") + .replace("è", "e") + .replace("é", "e") + .replace("à", "a") + .replace(" ", "_") + .replaceAll("[^A-Za-z0-9_]", ""); + } + } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamCreateClientConfigPopup.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamCreateClientConfigPopup.java index 1a480391..20012a3d 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamCreateClientConfigPopup.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamCreateClientConfigPopup.java @@ -14,7 +14,6 @@ import java.util.function.Predicate; import java.util.function.Supplier; import java.util.stream.Collectors; -import org.apache.commons.lang3.StringUtils; import org.eclipse.rap.rwt.RWT; import org.eclipse.rap.rwt.client.service.UrlLauncher; import org.eclipse.swt.widgets.Composite; @@ -74,8 +73,9 @@ public class ExamCreateClientConfigPopup { return action -> { final DateTime now = DateTime.now(DateTimeZone.UTC); - final String downloadFileName = StringUtils.remove(examName, " ") + "_" + now.getYear() + "-" - + now.getMonthOfYear() + "-" + now.getDayOfMonth() + ".seb"; + final String downloadFileName = + Utils.toFileName(examName) + "_" + now.getYear() + "-" + + now.getMonthOfYear() + "-" + now.getDayOfMonth() + ".seb"; final ModalInputDialog> dialog = new ModalInputDialog>(