NOT(..) is a safe evaluation

This commit is contained in:
Sergey
2017-04-12 15:08:21 -07:00
parent 523495750f
commit e7bcf6fdfa
4 changed files with 36 additions and 17 deletions

View File

@ -145,7 +145,7 @@ PARSER_END(VfParser)
| <GE: ">=" > | <GE: ">=" >
| <LT: "<" > | <LT: "<" >
| <GT: ">" > | <GT: ">" >
| <EXCL: ("!"|"~"|"NOT") > | <EXCL: ("!"|"~") >
| <PIPE_PIPE: "||" > | <PIPE_PIPE: "||" >
| <STRING_LITERAL: <QUOTED_STRING> > | <STRING_LITERAL: <QUOTED_STRING> >
| <DIGITS: (<NUM_CHAR>)+ (<DOT> (<NUM_CHAR>)+)? > | <DIGITS: (<NUM_CHAR>)+ (<DOT> (<NUM_CHAR>)+)? >
@ -476,10 +476,10 @@ void UnaryExpression() #void :
{} {}
{ {
( <PLUS> | <MINUS> ) UnaryExpression() ( <PLUS> | <MINUS> ) UnaryExpression()
| UnaryExpressionNotPlusMinus() | NegationExpression()
} }
void UnaryExpressionNotPlusMinus() #void : void NegationExpression() #void :
{} {}
{ {
( <EXCL> ) UnaryExpression() ( <EXCL> ) UnaryExpression()

View File

@ -93,5 +93,5 @@ public class VfParserVisitorAdapter implements VfParserVisitor {
public Object visit(ASTContent node, Object data) { public Object visit(ASTContent node, Object data) {
return visit((VfNode) node, data); return visit((VfNode) node, data);
} }
} }

View File

@ -230,20 +230,24 @@ public class VfUnescapeElRule extends AbstractVfRule {
if (expression != null) { if (expression != null) {
final ASTIdentifier id = expression.getFirstChildOfType(ASTIdentifier.class); final ASTIdentifier id = expression.getFirstChildOfType(ASTIdentifier.class);
if (id != null) { if (id != null) {
switch (id.getImage().toLowerCase()) { List<ASTArguments> args = expression.findChildrenOfType(ASTArguments.class);
case "$component": if (!args.isEmpty()) {
case "$objecttype": switch (id.getImage().toLowerCase()) {
case "$label": case "$component":
case "$resource": case "$objecttype":
case "urlfor": case "$label":
case "$site": case "$resource":
case "$page": case "urlfor":
case "$action": case "$site":
case "casesafeid": case "$page":
case "$remoteaction": case "$action":
return true; case "casesafeid":
case "not":
case "$remoteaction":
return true;
default: default:
}
} }
} }

View File

@ -557,5 +557,20 @@ Safe unquoted followed by safe quoted
]]></code> ]]></code>
<source-type>vf</source-type> <source-type>vf</source-type>
</test-code> </test-code>
<test-code>
<description><![CDATA[
NOT method evaluates to safe boolean
]]></description>
<expected-problems>0</expected-problems>
<code><![CDATA[
<apex:page>
<script>
if({!NOT(yes)}) { maskFormEls(); }
</script>
</apex:page>
]]></code>
<source-type>vf</source-type>
</test-code>
</test-data> </test-data>