markt-asf commented on code in PR #818:
URL: https://github.com/apache/tomcat/pull/818#discussion_r1944967982
##########
java/org/apache/tomcat/util/http/RequestUtil.java:
##########
@@ -123,19 +123,12 @@ public static boolean isSameOrigin(HttpServletRequest
request, String origin) {
// Build scheme://host:port from request
StringBuilder target = new StringBuilder();
String scheme = request.getScheme();
- if (scheme == null) {
- return false;
- } else {
- scheme = scheme.toLowerCase(Locale.ENGLISH);
- }
- target.append(scheme);
- target.append("://");
-
String host = request.getServerName();
- if (host == null) {
+ if (scheme == null || host == null) {
return false;
}
- target.append(host);
+ scheme = scheme.toLowerCase(Locale.ENGLISH);
+ target.append(scheme).append("://").append(host);
Review Comment:
It is marginally less efficient because it calls request.getServerName()
even if the scheme is null. But it isn't a big deal.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]