Skip to content

Commit

Permalink
#339 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ryaneberly committed Jul 17, 2017
1 parent d86b759 commit 71bc823
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 1 deletion.
40 changes: 39 additions & 1 deletion src/main/java/com/cflint/CFLint.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
import cfml.parsing.cfscript.script.CFTryCatchStatement;
import cfml.parsing.reporting.IErrorReporter;
import cfml.parsing.reporting.ParseException;
import net.htmlparser.jericho.Attribute;
import net.htmlparser.jericho.Element;
import net.htmlparser.jericho.EndTag;
import net.htmlparser.jericho.Source;
Expand Down Expand Up @@ -488,6 +489,11 @@ private void process(final Element elem, final String space, final Context conte
handler.pop();
} else {
scanElement(elem, context);
for(final CFExpression expression : unpackTagExpressions(elem)){
if (expression != null) {
process(expression, elem, context);
}
}
processStack(elem.getChildElements(), space + " ", context);
}
// Process any messages added by downstream parsing.
Expand All @@ -497,7 +503,39 @@ private void process(final Element elem, final String space, final Context conte
context.getMessages().clear();
}

protected void scanElement(final Element elem, final Context context) {
private List<CFExpression> unpackTagExpressions(final Element elem) {
final List<CFExpression> expressions = new ArrayList<CFExpression>();
if(elem.getAttributes()==null){
return expressions;
}
//Explicitly unpack cfloop
if (elem.getName().equalsIgnoreCase("cfloop")){
List<String> attributes = Arrays.asList("from","to","step","condition","array","list","delimiters");
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().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());
}
}
}
}
return expressions;
}

protected void scanElement(final Element elem, final Context context) {
for (final CFLintScanner plugin : extensions) {
try {
plugin.element(elem, context, bugs);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<cfcomponent>
<cffunction name="foo">
<cfset var sRememberUserCookieKey = getRememberUserLoginCookieName()>
<cfcookie name="#sRememberUserCookieKey#" value="#sCookieValue#" expires="#sExpirePeriod#">
</cffunction>
</cfcomponent>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[ {
"totalfiles" : 0
}, {
"totalsize" : 0
} ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<cfcomponent>
<cffunction name="foo">
<cfset var sCoreURL = stContens.sCoreURL>
<cflocation url="#sCoreURL#contens/index.cfm#sLoginParams#" addtoken="No">
</cffunction>
</cfcomponent>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[ {
"totalfiles" : 0
}, {
"totalsize" : 0
} ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<cfcomponent>
<cffunction name="foo">
<cfset var lLoginURLParams = stContens.security.lLoginURLParams>
<cfloop list="#lLoginURLParams#" index="sParam">
</cffunction>
</cfcomponent>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[ {
"totalfiles" : 0
}, {
"totalsize" : 0
} ]

0 comments on commit 71bc823

Please sign in to comment.