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

@@ -182,7 +182,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
@Override
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
}
else if (logger.isTraceEnabled()) {

View File

@@ -147,11 +147,10 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
"At least 2 characters ([]) required in attributes CSV string '" + propString + "'");
}
String name = tok.substring(0, eqIdx);
String value = tok.substring(eqIdx + 1);
// Delete first and last characters of value: { and }
value = value.substring(1);
value = value.substring(0, value.length() - 1);
int beginIndex = eqIdx + 2;
int endIndex = tok.length() - 1;
String value = tok.substring(beginIndex, endIndex);
addStaticAttribute(name, value);
}