forked from phoedos/pmd
fix for unbalanced quotes
This commit is contained in:
@ -72,13 +72,8 @@ public class VfUnescapeElRule extends AbstractVfRule {
|
||||
boolean quoted = false;
|
||||
|
||||
if (prevText != null) {
|
||||
if ("'".equals(prevText.jjtGetLastToken()) || "\"".equals(prevText.jjtGetLastToken())) {
|
||||
if (isUnbalanced(prevText.getImage(), "'") || isUnbalanced(prevText.getImage(), "\"")) {
|
||||
quoted = true;
|
||||
} else {
|
||||
if (prevText.getImage() != null
|
||||
&& (prevText.getImage().contains("'") | prevText.getImage().contains("\""))) {
|
||||
quoted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (quoted) {
|
||||
@ -95,6 +90,22 @@ public class VfUnescapeElRule extends AbstractVfRule {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isUnbalanced(String image, String pattern) {
|
||||
int occurance = 0;
|
||||
int index = image.lastIndexOf("=");
|
||||
index = image.indexOf(pattern, index + 1);
|
||||
while (index >= 0) {
|
||||
occurance++;
|
||||
index = image.indexOf(pattern, index + 1);
|
||||
}
|
||||
|
||||
if ((occurance % 2) != 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(ASTElement node, Object data) {
|
||||
if (doesTagSupportEscaping(node)) {
|
||||
|
Reference in New Issue
Block a user