Skip to content

Commit

Permalink
string replacement without regex
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Jan 10, 2024
1 parent 78daf1f commit 4eb8a9f
Showing 1 changed file with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -853,39 +853,39 @@ public static String getNewFileName(String currentFileName, boolean datetimePref

public static String sanitizeFileName(String fileName) {
String name = fileName;
name = name.replaceAll(",", " ");
name = name.replaceAll("\"", "");
name = name.replaceAll("§", " ");
name = name.replaceAll("%", " ");
name = name.replaceAll("&", "_");
name = name.replaceAll("/", "_");
name = name.replaceAll("=", "_");
name = name.replaceAll("\\?", " ");
name = name.replaceAll("\\{", "(");
name = name.replaceAll("\\}", ")");
name = name.replaceAll("\\[", "(");
name = name.replaceAll("\\]", ")");
name = name.replaceAll("\\\\", "_");
name = name.replaceAll("\\*", "-");
name = name.replaceAll("#", "-");
name = name.replaceAll("'", "");
name = name.replaceAll(":", " ");
name = name.replaceAll(";", " ");
name = name.replaceAll(">", "");
name = name.replaceAll("<", "");
name = name.replaceAll("\\|", "_");
name = name.replace(",", " ");
name = name.replace("\"", "");
name = name.replace("§", " ");
name = name.replace("%", " ");
name = name.replace("&", "_");
name = name.replace("/", "_");
name = name.replace("=", "_");
name = name.replace("?", " ");
name = name.replace("{", "(");
name = name.replace("}", ")");
name = name.replace("[", "(");
name = name.replace("]", ")");
name = name.replace("\\", "_");
name = name.replace("*", "-");
name = name.replace("#", "-");
name = name.replace("'", "");
name = name.replace(":", " ");
name = name.replace(";", " ");
name = name.replace(">", "");
name = name.replace("<", "");
name = name.replace("|", "_");
return name.trim();
}

public static String sanitizeAttachmentName(String fileName) {
String name = sanitizeFileName(fileName);
name = name.replaceAll("ä", "ae");
name = name.replaceAll("ö", "oe");
name = name.replaceAll("ü", "ue");
name = name.replaceAll("Ä", "Ae");
name = name.replaceAll("Ö", "Oe");
name = name.replaceAll("Ü", "Ue");
name = name.replaceAll("ß", "ss");
name = name.replace("ä", "ae");
name = name.replace("ö", "oe");
name = name.replace("ü", "ue");
name = name.replace("Ä", "Ae");
name = name.replace("Ö", "Oe");
name = name.replace("Ü", "Ue");
name = name.replace("ß", "ss");
name=name.trim();
if(name.indexOf('.')==0)
name="Anhang_"+System.currentTimeMillis()+name;
Expand All @@ -894,8 +894,8 @@ public static String sanitizeAttachmentName(String fileName) {

public static String sanitizeFolderName(String folderName) {
String sanitized = sanitizeFileName(folderName);
sanitized = sanitized.replaceAll(" ", " ");
sanitized = sanitized.replaceAll(" ", " ");
sanitized = sanitized.replace(" ", " ");
sanitized = sanitized.replace(" ", " ");
return sanitized;
}

Expand Down

0 comments on commit 4eb8a9f

Please sign in to comment.