fix for unbalanced quotes

This commit is contained in:
Sergey
2017-03-02 15:47:47 -08:00
parent b7946ba4d1
commit 32762c48d1

View File

@ -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)) {