From ea50fd13ac89f90e2471833cf1af72b6a71c0954 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Sun, 3 Jul 2022 21:30:12 +0200 Subject: [PATCH] fix script tags --- src/de/tudbut/tryumph/example/Main.java | 2 -- src/de/tudbut/tryumph/server/BrowserContext.java | 4 +--- src/de/tudbut/tryumph/server/HTMLParsing.java | 11 ++++++++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/de/tudbut/tryumph/example/Main.java b/src/de/tudbut/tryumph/example/Main.java index 559296e..c8cb167 100644 --- a/src/de/tudbut/tryumph/example/Main.java +++ b/src/de/tudbut/tryumph/example/Main.java @@ -26,7 +26,6 @@ public class Main implements IRequestCatcher { @Override public TaskCallable> onConnect(Socket socket) { return (tres, trej) -> tres.call((resp, res, rej) -> { - System.out.println(resp.toString()); listener.handle(resp, r -> { if(r.isHTML) { Document html = r.getHTML(); @@ -59,7 +58,6 @@ public class Main implements IRequestCatcher { @Path("/") public void onIndex(Request request, Callback res, Callback rej) { Response r = new Response(request, request.context.file("index.html"), 200, "OK"); - System.out.println(r.getHTMLData()); Document html = r.getHTML(); Node node = html.createTextNode(request.fingerPrint()); HTMLParsing.getElementById(html, "fingerprint").appendChild(node); diff --git a/src/de/tudbut/tryumph/server/BrowserContext.java b/src/de/tudbut/tryumph/server/BrowserContext.java index bf0121d..5953f33 100644 --- a/src/de/tudbut/tryumph/server/BrowserContext.java +++ b/src/de/tudbut/tryumph/server/BrowserContext.java @@ -2,7 +2,6 @@ package de.tudbut.tryumph.server; import static de.tudbut.async.Async.*; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; @@ -35,9 +34,7 @@ public class BrowserContext { private BrowserContext(String cookie, IRequestCatcher requestCatcher) { this.requestCatcher = requestCatcher; try { - System.out.println("Reading cookie"); data = AsyncJSON.read(cookie).err(e -> {throw new RuntimeException(e);}).ok().await(); - System.out.println("Read cookie"); } catch (Exception e) { data = new TCN("JSON"); } @@ -68,6 +65,7 @@ public class BrowserContext { private Task init() { return t((res, rej) -> { requestCatcher.processBrowserContext(this).err(rej).then(res).ok(); + needsChange = true; }); } diff --git a/src/de/tudbut/tryumph/server/HTMLParsing.java b/src/de/tudbut/tryumph/server/HTMLParsing.java index d9df28a..dc823a3 100644 --- a/src/de/tudbut/tryumph/server/HTMLParsing.java +++ b/src/de/tudbut/tryumph/server/HTMLParsing.java @@ -2,6 +2,8 @@ package de.tudbut.tryumph.server; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintWriter; import java.io.StringReader; import java.io.Writer; @@ -22,7 +24,14 @@ public class HTMLParsing { tidy.setDropProprietaryTags(false); tidy.setDropProprietaryAttributes(false); tidy.setSpaces(4); - tidy.setXHTML(true); + tidy.setShowWarnings(false); + tidy.setShowErrors(0); + tidy.setErrout(new PrintWriter(new OutputStream() { + @Override + public void write(int b) throws IOException { + // do nothing. we dont want output! + } + })); }