reiern70 commented on code in PR #1673:
URL: https://github.com/apache/wicket/pull/1673#discussion_r4300825615
##########
wicket-request/src/main/java/org/apache/wicket/request/Url.java:
##########
@@ -434,6 +434,29 @@ else if ("ftp".equals(protocol))
}
}
+ /**
+ * Parses the port part of the authority. A value that is not a number
falls back to the
+ * default port of the protocol, so that a malformed port does not make
the whole URL
+ * unparseable.
+ *
+ * @param port
+ * the port part of the authority
+ * @param protocol
+ * name of protocol
+ * @return the port, or the default port for the protocol if the value
cannot be parsed
+ */
+ private static Integer parsePort(String port, String protocol)
+ {
+ try
+ {
+ return Integer.parseInt(port);
+ }
+ catch (NumberFormatException e)
+ {
+ return getDefaultPortForProtocol(protocol);
Review Comment:
This only catches ports that aren't an `int` at all. `:-1` and `:70000` are
still taken as they are, so whether a bad port is replaced depends on whether
it happens to fit an `int`; `parse23` locks in `99999999999` becoming 443 while
`70000` stays 70000.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]