i2ptunnel, eepget: Better error message on invalid URLs (ticket #2130)

This commit is contained in:
zzz
2018-01-06 10:31:41 +00:00
parent 62210c8165
commit d82499f07c
3 changed files with 11 additions and 1 deletions

View File

@ -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) {

View File

@ -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);
}

View File

@ -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>