Skip to content

Commit

Permalink
Showing 4 changed files with 47 additions and 21 deletions.
49 changes: 28 additions & 21 deletions src/main/java/com/cflint/CFLint.java
Original file line number Diff line number Diff line change
@@ -518,28 +518,35 @@ private List<CFExpression> unpackTagExpressions(final Element elem) {
}
//Explicitly unpack cfloop
if (elem.getName().equalsIgnoreCase("cfloop")){
List<String> attributes = Arrays.asList("from","to","step","condition","array","list");
for(Attribute attr: elem.getAttributes()){
if(attributes.contains(attr.getName().toLowerCase()) && attr.getValue().trim().length()>0){
try {
expressions.add(cfmlParser.parseCFExpression(attr.getValue(), this));
} catch (Exception e) {
System.err.println("Error in parsing : " + attr.getValue() + " on tag " + elem.getName());
}
}
}
List<String> attributes = Arrays.asList("from", "to", "step", "condition", "array", "list");
for (Attribute attr : elem.getAttributes()) {
if (attributes.contains(attr.getName().toLowerCase()) && attr.getValue().trim().length() > 0) {
try {
expressions.add(cfmlParser.parseCFExpression(attr.getValue(), this));
} catch (Exception e) {
System.err.println("Error in parsing : " + attr.getValue() + " on tag " + elem.getName());
}
}
}
}else{ //Unpack any attributes that have a hash expression
for(Attribute attr: elem.getAttributes()){
if(attr.getValue() != null && attr.getValue().contains("#") && !attr.getValue().startsWith("'") && !attr.getValue().startsWith("\"")){
try {
CFExpression exp = cfmlParser.parseCFExpression("'" +attr.getValue() + "'", this);
expressions.add(exp);
} catch (Exception e) {
System.err.println("Error in parsing : " + attr.getValue() + " on tag " + elem.getName());
}
}
}
}
for (Attribute attr : elem.getAttributes()) {
if (attr.getValue() != null && attr.getValue().contains("#") && !attr.getValue().startsWith("'")
&& !attr.getValue().startsWith("\"")) {
try {
final CFExpression exp = cfmlParser.parseCFExpression("\"" + attr.getValue() + "\"", this);
expressions.add(exp);
} catch (Exception e) {
// Try single quotes before reporting a failure
try {
final CFExpression exp = cfmlParser.parseCFExpression("'" + attr.getValue() + "'", this);
expressions.add(exp);
} catch (Exception e2) {
System.err.println("Error in parsing : " + attr.getValue() + " on tag " + elem.getName());
}
}
}
}
}
return expressions;
}

9 changes: 9 additions & 0 deletions src/test/resources/com/cflint/tests/ParseError/.cflintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"output" : [ ],
"rule" : [ ],
"excludes" : [ ],
"includes" : [ {
"code" : "PARSE_ERROR"
} ],
"inheritParent" : false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<cfcomponent>
<cffunction name="foo">
<cfinvokeargument name="x" value="#someVar# & '_' & #someOtherVar#">
</cffunction>
</cfcomponent>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[ {
"totalfiles" : 0
}, {
"totalsize" : 0
} ]

0 comments on commit 3d21f64

Please sign in to comment.