From d82499f07cedfd15521c9eea4bc6b9b01301af10 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Sat, 6 Jan 2018 10:31:41 +0000 Subject: [PATCH] i2ptunnel, eepget: Better error message on invalid URLs (ticket #2130) --- .../java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java | 8 ++++++++ core/java/src/net/i2p/util/EepGet.java | 3 +++ installer/resources/proxy/baduri-header.ht | 1 - 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java index 8554421cd0..d7d5d70e95 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java @@ -501,8 +501,16 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn if(_log.shouldLog(Log.WARN)) { _log.warn(getPrefix(requestId) + "Bad request [" + request + "]", use); } + // TODO fixup []| not escaped by browsers try { out.write(getErrorPage("baduri", ERR_BAD_URI).getBytes("UTF-8")); + String msg = use.getLocalizedMessage(); + if (msg != null) { + out.write(DataHelper.getASCII("<p>\n")); + out.write(DataHelper.getUTF8(DataHelper.escapeHTML(msg))); + out.write(DataHelper.getASCII("</p>\n")); + } + out.write(DataHelper.getASCII("</div>\n")); writeFooter(out); reader.drain(); } catch (IOException ioe) { diff --git a/core/java/src/net/i2p/util/EepGet.java b/core/java/src/net/i2p/util/EepGet.java index 478d2f62f2..8582956680 100644 --- a/core/java/src/net/i2p/util/EepGet.java +++ b/core/java/src/net/i2p/util/EepGet.java @@ -327,6 +327,9 @@ public class EepGet { try { nameURL = new URI(url); } catch (URISyntaxException e) { + String msg = e.getLocalizedMessage(); + if (msg != null) + System.err.println(msg); System.err.println("Please enter a properly formed URL."); System.exit(1); } diff --git a/installer/resources/proxy/baduri-header.ht b/installer/resources/proxy/baduri-header.ht index 0f8e532210..0855dbdeb3 100644 --- a/installer/resources/proxy/baduri-header.ht +++ b/installer/resources/proxy/baduri-header.ht @@ -21,4 +21,3 @@ Proxy-Connection: close _("The request URI is invalid, and probably contains illegal characters.") _("If you clicked a link, check the end of the URI for any characters the browser has mistakenly added on.") </p> -</div> -- GitLab