diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index f93e09853a..90adef0e1c 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -30,6 +30,8 @@ This is a {{ site.pmd.release_type }} release. * [#2764](https://github.com/pmd/pmd/issues/2764): \[java] CloseResourceRule does not recognize multiple assignment done to resource * miscellaneous * [#2823](https://github.com/pmd/pmd/issues/2823): \[doc] Renamed/Moved rules are missing in documentation +* vf (Salesforce VisualForce) + * [#2765](https://github.com/pmd/pmd/issues/2765): \[vf] Attributes with dot cause a VfParseException ### API Changes @@ -41,6 +43,7 @@ This is a {{ site.pmd.release_type }} release. * [#2811](https://github.com/pmd/pmd/pull/2811): \[java] CloseResource - Fix #2764: False-negative when re-assigning variable - [Andi Pabst](https://github.com/andipabst) * [#2813](https://github.com/pmd/pmd/pull/2813): \[core] Use JUnit's TemporaryFolder rule - [Stefan Birkner](https://github.com/stefanbirkner) * [#2829](https://github.com/pmd/pmd/pull/2829): \[doc] Small correction in pmd\_report\_formats.md - [Gustavo Krieger](https://github.com/gustavopcassol) +* [#2834](https://github.com/pmd/pmd/pull/2834): \[vf] Allow attributes with dot in Visualforce - [rmohan20](https://github.com/rmohan20) {% endtocmaker %} diff --git a/pmd-visualforce/etc/grammar/VfParser.jjt b/pmd-visualforce/etc/grammar/VfParser.jjt index 5e1bbf20d1..a97ba3629f 100644 --- a/pmd-visualforce/etc/grammar/VfParser.jjt +++ b/pmd-visualforce/etc/grammar/VfParser.jjt @@ -67,6 +67,7 @@ PARSER_END(VfParser) | <#ALPHANUM_CHAR: ( | ) > | <#IDENTIFIER_CHAR: ( | [ "_", "-", ":" ] ) > | <#IDENTIFIER: ()* > +| <#IDENTIFIER_DOTTED: ( )+ > | <#XMLNAME: ( | "_" | ":") ()* > | <#QUOTED_STRING_NO_BREAKS: ( "'" ( ~["'", "\r", "\n"] )* "'" ) | ( "\"" ( ~["\"", "\r", "\n"] )* "\"" ) > @@ -216,7 +217,7 @@ PARSER_END(VfParser) TOKEN : { - > + | > | " > : AfterTagState | " | "!>") > : AfterTagState | " | "/ >") > : AfterTagState diff --git a/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/ast/VfParserTest.java b/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/ast/VfParserTest.java index f425470314..6ce22de09c 100644 --- a/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/ast/VfParserTest.java +++ b/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/ast/VfParserTest.java @@ -6,6 +6,8 @@ package net.sourceforge.pmd.lang.vf.ast; import org.junit.Test; +import net.sourceforge.pmd.lang.ast.ParseException; + /** * @author sergey.gorbaty */ @@ -26,4 +28,39 @@ public class VfParserTest extends AbstractVfNodesTest { vf.parse("${\"yes\"}"); } + @Test + public void testAttributeNameWithDot() { + vf.parse(""); + } + + @Test + public void testAttributeNameWithUnderscore() { + vf.parse(""); + } + + @Test + public void testAttributeNameWithColon() { + vf.parse(""); + } + + @Test(expected = ParseException.class) + public void testAttributeNameWithInvalidSymbol() { + vf.parse(""); + } + + @Test(expected = ParseException.class) + public void testAttributeNameWithInvalidDot() { + vf.parse(""); + } + + @Test(expected = ParseException.class) + public void testAttributeNameWithInvalidDotV2() { + vf.parse(""); + } + + @Test(expected = ParseException.class) + public void testAttributeNameWithInvalidDotV3() { + vf.parse(""); + } + } diff --git a/pmd-visualforce/src/test/resources/net/sourceforge/pmd/lang/vf/cpd/testdata/SampleUnescapeElWithTab.txt b/pmd-visualforce/src/test/resources/net/sourceforge/pmd/lang/vf/cpd/testdata/SampleUnescapeElWithTab.txt index 6453afcb92..3b279e6b92 100644 --- a/pmd-visualforce/src/test/resources/net/sourceforge/pmd/lang/vf/cpd/testdata/SampleUnescapeElWithTab.txt +++ b/pmd-visualforce/src/test/resources/net/sourceforge/pmd/lang/vf/cpd/testdata/SampleUnescapeElWithTab.txt @@ -1,42 +1,42 @@ [Image] or [Truncated image[ Bcol Ecol L1 - [24] 1 1 - [85] 2 10 - [88] 11 11 + [25] 1 1 + [86] 2 10 + [89] 11 11 L2 - [24] 2 2 - [85] 3 6 - [87] 8 10 - [91] 11 11 - [94] 12 12 - [105] 13 22 - [103] 23 23 - [87] 25 28 - [91] 29 29 - [94] 30 30 - [105] 31 38 - [103] 39 39 - [87] 41 44 - [91] 45 45 - [94] 46 46 - [104] 47 48 - [66] 49 57 - [41] 58 58 - [66] 59 67 - [73] 68 68 - [105] 69 69 - [104] 70 71 - [66] 72 81 - [73] 82 82 - [103] 83 83 - [87] 85 86 - [91] 87 87 - [94] 88 88 - [105] 89 99 - [103] 100 100 - [90] 101 102 + [25] 2 2 + [86] 3 6 + [88] 8 10 + [92] 11 11 + [95] 12 12 + [106] 13 22 + [104] 23 23 + [88] 25 28 + [92] 29 29 + [95] 30 30 + [106] 31 38 + [104] 39 39 + [88] 41 44 + [92] 45 45 + [95] 46 46 + [105] 47 48 + [67] 49 57 + [42] 58 58 + [67] 59 67 + [74] 68 68 + [106] 69 69 + [105] 70 71 + [67] 72 81 + [74] 82 82 + [104] 83 83 + [88] 85 86 + [92] 87 87 + [95] 88 88 + [106] 89 99 + [104] 100 100 + [91] 101 102 L3 - [25] 1 2 - [85] 3 11 - [88] 12 12 + [26] 1 2 + [86] 3 11 + [89] 12 12 EOF