From 6700d152e9293f392ba61a0f89686e9739944412 Mon Sep 17 00:00:00 2001 From: ulrich Date: Sat, 26 Oct 2024 12:18:10 +0000 Subject: [PATCH] fixFileName hinzugefuegt --- src/de/uhilger/neon/adoc/AdocFilter.java | 30 +++++++++++++++++++----------- 1 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/de/uhilger/neon/adoc/AdocFilter.java b/src/de/uhilger/neon/adoc/AdocFilter.java index 7a304e1..c0cca3b 100644 --- a/src/de/uhilger/neon/adoc/AdocFilter.java +++ b/src/de/uhilger/neon/adoc/AdocFilter.java @@ -21,6 +21,7 @@ import com.sun.net.httpserver.HttpContext; import com.sun.net.httpserver.HttpExchange; import de.uhilger.neon.FileServer; +import de.uhilger.neon.HttpHelper; import java.io.File; import java.io.IOException; import java.net.URI; @@ -37,19 +38,26 @@ @Override public void doFilter(HttpExchange exchange, Chain chain) throws IOException { URI uri = exchange.getRequestURI(); - String path = uri.getPath(); - if(path.endsWith(".adoc")) { - HttpContext ctx = exchange.getHttpContext(); - String fileBase = ctx.getAttributes().get(FileServer.ATTR_FILE_BASE).toString(); - String fileName = path.substring(ctx.getPath().length()); - String query = uri.getQuery(); - if (query instanceof String && query.contains("pdf=true")) { - processAdocFile(new File(fileBase, fileName), true); - } else { - processAdocFile(new File(fileBase, fileName), false); + //String path = uri.getPath(); + try { + String path = new HttpHelper().getFileName(exchange); + if(path.endsWith(".adoc")) { + HttpContext ctx = exchange.getHttpContext(); + String fileBase = ctx.getAttributes().get(FileServer.ATTR_FILE_BASE).toString(); + String fileName = path.substring(ctx.getPath().length()); + String query = uri.getQuery(); + if (query instanceof String && query.contains("pdf=true")) { + processAdocFile(new File(fileBase, fileName), true); + } else { + processAdocFile(new File(fileBase, fileName), false); + } } + } catch (IllegalArgumentException ex) { + // ungueltiger Dateiname, keine Transformation noetig, also tue nichts + } finally { + chain.doFilter(exchange); } - chain.doFilter(exchange); + } /** -- Gitblit v1.9.3