Improve usage of String.substring()

Closes gh-23923
This commit is contained in:
stsypanov
2019-11-03 22:05:12 +02:00
committed by Sam Brannen
parent f9c1f136c3
commit 9da15ee23a
5 changed files with 11 additions and 13 deletions

View File

@@ -472,8 +472,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
private boolean validatePath(ServerHttpRequest request) {
String path = request.getURI().getPath();
int index = path.lastIndexOf('/') + 1;
String filename = path.substring(index);
return (filename.indexOf(';') == -1);
return path.indexOf(';', index) == -1;
}
protected boolean checkOrigin(ServerHttpRequest request, ServerHttpResponse response, HttpMethod... httpMethods)
@@ -571,7 +570,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
sendMethodNotAllowed(response, HttpMethod.GET, HttpMethod.OPTIONS);
}
}
};
}
private class IframeHandler implements SockJsRequestHandler {
@@ -622,6 +621,6 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
response.getHeaders().setETag(etagValue);
response.getBody().write(contentBytes);
}
};
}
}