Improve usage of String.substring()
Closes gh-23923
This commit is contained in:
@@ -127,9 +127,9 @@ public class AspectMetadata implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String findPerClause(Class<?> aspectClass) {
|
private String findPerClause(Class<?> aspectClass) {
|
||||||
String str = aspectClass.getAnnotation(Aspect.class).value();
|
String str = aspectClass.getAnnotation(Aspect.class).value();
|
||||||
str = str.substring(str.indexOf('(') + 1);
|
int beginIndex = str.indexOf('(') + 1;
|
||||||
str = str.substring(0, str.length() - 1);
|
int endIndex = str.length() - 1;
|
||||||
return str;
|
return str.substring(beginIndex, endIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int extractUnquotedLink(int position, String content, Set<ContentChunkInfo> result) {
|
protected int extractUnquotedLink(int position, String content, Set<ContentChunkInfo> result) {
|
||||||
if (content.substring(position, position + 4).equals("url(")) {
|
if (content.startsWith("url(", position)) {
|
||||||
// Ignore, UrlFunctionContentParser will take care
|
// Ignore, UrlFunctionContentParser will take care
|
||||||
}
|
}
|
||||||
else if (logger.isTraceEnabled()) {
|
else if (logger.isTraceEnabled()) {
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int extractLink(int index, String content, SortedSet<ContentChunkInfo> linksToAdd) {
|
protected int extractLink(int index, String content, SortedSet<ContentChunkInfo> linksToAdd) {
|
||||||
if (content.substring(index, index + 4).equals("url(")) {
|
if (content.startsWith("url(", index)) {
|
||||||
// Ignore, UrlLinkParser will take care
|
// Ignore, UrlLinkParser will take care
|
||||||
}
|
}
|
||||||
else if (logger.isTraceEnabled()) {
|
else if (logger.isTraceEnabled()) {
|
||||||
|
|||||||
@@ -147,11 +147,10 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
|
|||||||
"At least 2 characters ([]) required in attributes CSV string '" + propString + "'");
|
"At least 2 characters ([]) required in attributes CSV string '" + propString + "'");
|
||||||
}
|
}
|
||||||
String name = tok.substring(0, eqIdx);
|
String name = tok.substring(0, eqIdx);
|
||||||
String value = tok.substring(eqIdx + 1);
|
|
||||||
|
|
||||||
// Delete first and last characters of value: { and }
|
// Delete first and last characters of value: { and }
|
||||||
value = value.substring(1);
|
int beginIndex = eqIdx + 2;
|
||||||
value = value.substring(0, value.length() - 1);
|
int endIndex = tok.length() - 1;
|
||||||
|
String value = tok.substring(beginIndex, endIndex);
|
||||||
|
|
||||||
addStaticAttribute(name, value);
|
addStaticAttribute(name, value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -472,8 +472,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
|
|||||||
private boolean validatePath(ServerHttpRequest request) {
|
private boolean validatePath(ServerHttpRequest request) {
|
||||||
String path = request.getURI().getPath();
|
String path = request.getURI().getPath();
|
||||||
int index = path.lastIndexOf('/') + 1;
|
int index = path.lastIndexOf('/') + 1;
|
||||||
String filename = path.substring(index);
|
return path.indexOf(';', index) == -1;
|
||||||
return (filename.indexOf(';') == -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean checkOrigin(ServerHttpRequest request, ServerHttpResponse response, HttpMethod... httpMethods)
|
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);
|
sendMethodNotAllowed(response, HttpMethod.GET, HttpMethod.OPTIONS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
private class IframeHandler implements SockJsRequestHandler {
|
private class IframeHandler implements SockJsRequestHandler {
|
||||||
@@ -622,6 +621,6 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
|
|||||||
response.getHeaders().setETag(etagValue);
|
response.getHeaders().setETag(etagValue);
|
||||||
response.getBody().write(contentBytes);
|
response.getBody().write(contentBytes);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user