From 4f2589e620f467d117003a908a0fc1bf2f3c476a Mon Sep 17 00:00:00 2001
From: ulrich
Date: Mon, 12 Apr 2021 06:22:58 +0000
Subject: [PATCH] titelErmitteln

---
 src/de/uhilger/mediaz/api/ListFileHandler.java |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/de/uhilger/mediaz/api/ListFileHandler.java b/src/de/uhilger/mediaz/api/ListFileHandler.java
index 0b780aa..e31d016 100644
--- a/src/de/uhilger/mediaz/api/ListFileHandler.java
+++ b/src/de/uhilger/mediaz/api/ListFileHandler.java
@@ -49,6 +49,9 @@
   /* Der Logger fuer diesen ListFileHandler */
   private static final Logger logger = Logger.getLogger(ListFileHandler.class.getName());
   
+  private static final String[] specialChars = {new String("\u00c4"), new String("\u00d6"), 
+      new String("\u00dc"), new String("\u00e4"), new String("\u00f6"), new String("\u00fc"), new String("\u00df")};
+  
   Map extMap = new HashMap();
   
   public ListFileHandler(String absoluteDirectoryPathAndName) {
@@ -119,10 +122,11 @@
         }
       }
       //Collections.sort(list);
-      String json = jsonWithCustomType(list, "Medialiste");
+      String json = escapeHtml(jsonWithCustomType(list, "Medialiste"));
+      
       logger.fine(json);
       Headers headers = e.getResponseHeaders();
-      headers.add("Content-Type", "application/json");
+      headers.add("Content-Type", "application/json; charset=UTF-8");
       e.sendResponseHeaders(200, json.length());
       OutputStream os = e.getResponseBody();
       os.write(json.getBytes());
@@ -132,6 +136,27 @@
     }
   }
   
+  public String escapeHtml(String text) {
+    text = text.replace(specialChars[0], "Ae");
+    text = text.replace(specialChars[1], "Oe");
+    text = text.replace(specialChars[2], "Ue");
+    text = text.replace(specialChars[3], "ae");
+    text = text.replace(specialChars[4], "oe");
+    text = text.replace(specialChars[5], "ue");
+    text = text.replace(specialChars[6], "ss");
+    
+    /*
+    text = text.replace(specialChars[0], "Ä");
+    text = text.replace(specialChars[1], "Ö");
+    text = text.replace(specialChars[2], "Ü");
+    text = text.replace(specialChars[3], "ä");
+    text = text.replace(specialChars[4], "ö");
+    text = text.replace(specialChars[5], "ü");
+    text = text.replace(specialChars[6], "ß");
+    */
+    return text;
+  }
+  
   private void getTrack(File file, StorageFile sf) {
     if(sf.getTyp().equalsIgnoreCase(StorageFile.TYP_AUDIO)) {
       Track track = new Track(file);

--
Gitblit v1.9.3