From f5a59207af78a92af9a4dba5c1d02a8882babc16 Mon Sep 17 00:00:00 2001 From: Sergey Date: Wed, 22 Feb 2017 09:47:07 -0800 Subject: [PATCH] Support for EL with no quotes --- pmd-visualforce/etc/grammar/VfParser.jjt | 40 +++++++++++++++++-- pmd-visualforce/src/main/ant/alljavacc.xml | 4 +- .../vf/rule/security/xml/VfUnescapeEl.xml | 7 +++- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/pmd-visualforce/etc/grammar/VfParser.jjt b/pmd-visualforce/etc/grammar/VfParser.jjt index e09593c705..24dce7a8b3 100644 --- a/pmd-visualforce/etc/grammar/VfParser.jjt +++ b/pmd-visualforce/etc/grammar/VfParser.jjt @@ -114,7 +114,7 @@ PARSER_END(VfParser) | |)+ > } - TOKEN : + TOKEN : { | @@ -170,6 +170,11 @@ PARSER_END(VfParser) )? > : AttrValueBetweenDoubleQuotesState } + TOKEN : +{ + )? > : AttrValueNoQuotesState +} + TOKEN : { )+ > @@ -214,9 +219,18 @@ PARSER_END(VfParser) { )? "'"> : AttrValueBetweenSingleQuotesState | )? "\"">: AttrValueBetweenDoubleQuotesState +| { input_stream.backup(1);} : AttrValueNoQuotesState | : InTagState //support for empty attributes } + TOKEN : +{ + : InTagState + | )? > : ElAttribTagStateNQ + | + +} + TOKEN : { : InTagState @@ -338,6 +352,19 @@ String Text() : } } + +String UnparsedTextNoWhitespace() #Text : +{ Token t;} +{ + ( + t = + ) + { + jjtThis.setImage(t.image); + return t.image; + } +} + /** * Text that contains no single quotes, and that does not contain the start * of a EL expression. @@ -468,7 +495,9 @@ void PrimaryPrefix() #void : { Literal() | Identifier() - | Expression() + | Expression() + | Expression() + } void PrimarySuffix() #void : @@ -482,7 +511,7 @@ void PrimarySuffix() #void : void DotExpression() : {} { - (Identifier() | BooleanLiteral() ) + (Identifier() | Literal() ) } @@ -534,6 +563,7 @@ void ElExpressionInAttribute() #ElExpression : { [Expression()] | [Expression()] + | [Expression()] } void CData() : @@ -614,6 +644,10 @@ void Attribute() : ( ( UnparsedTextNoSingleQuotes() | ElExpressionInAttribute() ) )* ( ) ) + | ( + ( ( UnparsedTextNoWhitespace() | ElExpressionInAttribute() ) )* + ( ) + ) | ) } diff --git a/pmd-visualforce/src/main/ant/alljavacc.xml b/pmd-visualforce/src/main/ant/alljavacc.xml index 6a1cf70f10..a8890aab8f 100644 --- a/pmd-visualforce/src/main/ant/alljavacc.xml +++ b/pmd-visualforce/src/main/ant/alljavacc.xml @@ -31,8 +31,10 @@ - + 0 -{! foo('test') } - +{!NoXSSHere(bah)} + ]]> vf @@ -127,6 +127,9 @@ No XSS via EL via param binding + + +