Ticket #891 - return "Invalid Request URI" for URIs with illegal characters

This commit is contained in:
str4d
2013-04-21 03:20:43 +00:00
parent 7371718afc
commit 075b1fd6f6
3 changed files with 42 additions and 1 deletions

View File

@ -162,6 +162,14 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
"<html><body><H1>I2P ERROR: NON-HTTP PROTOCOL</H1>" + "<html><body><H1>I2P ERROR: NON-HTTP PROTOCOL</H1>" +
"The request uses a bad 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.<BR>").getBytes(); "The I2P HTTP Proxy supports http:// requests ONLY. Other protocols such as https:// and ftp:// are not allowed.<BR>").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" +
"<html><body><H1>I2P ERROR: INVALID REQUEST URI</H1>" +
"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.<BR>").getBytes();
private final static byte[] ERR_LOCALHOST = private final static byte[] ERR_LOCALHOST =
("HTTP/1.1 403 Access Denied\r\n" + ("HTTP/1.1 403 Access Denied\r\n" +
"Content-Type: text/html; charset=iso-8859-1\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)) { if(_log.shouldLog(Log.WARN)) {
_log.warn(getPrefix(requestId) + "Bad request [" + request + "]", use); _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]; method = params[0];
String protocolVersion = params[2]; String protocolVersion = params[2];

View File

@ -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 2013-04-19 kytv
* Installer: Run fixperms.bat under any version of Windows that's not XP or * 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" 2003 to ensure it's run under Vista, 7, 8, and the upcoming "Blue"

View File

@ -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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<title>I2P Warning: Invalid Request URI</title>
<link rel="shortcut icon" href="http://proxy.i2p/themes/console/images/favicon.ico">
<link href="http://proxy.i2p/themes/console/default/console.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="logo">
<a href="http://127.0.0.1:7657/" title="Router Console"><img src="http://proxy.i2p/themes/console/images/i2plogo.png" alt="I2P Router Console" border="0"></a><hr>
<a href="http://127.0.0.1:7657/config.jsp">Configuration</a> <a href="http://127.0.0.1:7657/help.jsp">Help</a> <a href="http://127.0.0.1:7657/susidns/">Addressbook</a>
</div>
<div class="warning" id="warning">
<h3>Warning: Invalid Request URI</h3>
<p>
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.
</p>
</div>