diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java
index 2e41b9d828..eccdc480e8 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java
@@ -162,6 +162,14 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
"
I2P ERROR: NON-HTTP PROTOCOL
" +
"The request uses a bad protocol. " +
"The I2P HTTP Proxy supports http:// requests ONLY. Other protocols such as https:// and ftp:// are not allowed. ").getBytes();
+ private final static byte[] ERR_BAD_URI =
+ ("HTTP/1.1 403 Bad URI\r\n" +
+ "Content-Type: text/html; charset=iso-8859-1\r\n" +
+ "Cache-control: no-cache\r\n" +
+ "\r\n" +
+ "
I2P ERROR: INVALID REQUEST URI
" +
+ "The request URI is invalid, and probably contains illegal characters. " +
+ "If you clicked e.g. a forum link, check the end of the URI for any characters the browser has mistakenly added on. ").getBytes();
private final static byte[] ERR_LOCALHOST =
("HTTP/1.1 403 Access Denied\r\n" +
"Content-Type: text/html; charset=iso-8859-1\r\n" +
@@ -428,7 +436,12 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
if(_log.shouldLog(Log.WARN)) {
_log.warn(getPrefix(requestId) + "Bad request [" + request + "]", use);
}
- break;
+ if(out != null) {
+ out.write(getErrorPage("baduri", ERR_BAD_URI));
+ writeFooter(out);
+ }
+ s.close();
+ return;
}
method = params[0];
String protocolVersion = params[2];
diff --git a/history.txt b/history.txt
index 87168daa7f..1df2d64983 100644
--- a/history.txt
+++ b/history.txt
@@ -1,3 +1,7 @@
+2013-04-21 str4d
+ * i2ptunnel: Return "Invalid Request URI" instead of "Non-HTTP Protocol" for
+ URIs with illegal characters (ticket #891)
+
2013-04-19 kytv
* Installer: Run fixperms.bat under any version of Windows that's not XP or
2003 to ensure it's run under Vista, 7, 8, and the upcoming "Blue"
diff --git a/installer/resources/proxy/baduri-header.ht b/installer/resources/proxy/baduri-header.ht
new file mode 100644
index 0000000000..49fb39a835
--- /dev/null
+++ b/installer/resources/proxy/baduri-header.ht
@@ -0,0 +1,24 @@
+HTTP/1.1 403 Bad URI
+Content-Type: text/html; charset=UTF-8
+Cache-control: no-cache
+Connection: close
+Proxy-Connection: close
+
+
+
+I2P Warning: Invalid Request URI
+
+
+
+
+
+The request URI is invalid, and probably contains illegal characters.
+If you clicked e.g. a forum link, check the end of the URI for any characters the browser has mistakenly added on.
+