Merge branch 'pr-2834' into master

[vf] Allow attributes with dot in Visualforce #2834
This commit is contained in:
Andreas Dangel
2020-10-22 09:48:36 +02:00
4 changed files with 79 additions and 38 deletions

View File

@ -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 %}

View File

@ -67,6 +67,7 @@ PARSER_END(VfParser)
| <#ALPHANUM_CHAR: ( <ALPHA_CHAR> | <NUM_CHAR> ) >
| <#IDENTIFIER_CHAR: ( <ALPHANUM_CHAR> | [ "_", "-", ":" ] ) >
| <#IDENTIFIER: <ALPHA_CHAR> (<IDENTIFIER_CHAR>)* >
| <#IDENTIFIER_DOTTED: <IDENTIFIER> (<DOT> <IDENTIFIER>)+ >
| <#XMLNAME: (<ALPHA_CHAR> | "_" | ":") (<IDENTIFIER_CHAR>)* >
| <#QUOTED_STRING_NO_BREAKS: ( "'" ( ~["'", "\r", "\n"] )* "'" )
| ( "\"" ( ~["\"", "\r", "\n"] )* "\"" ) >
@ -216,7 +217,7 @@ PARSER_END(VfParser)
<InTagState> TOKEN :
{
<ATTR_NAME: <IDENTIFIER> >
<ATTR_NAME: <IDENTIFIER> | <IDENTIFIER_DOTTED> >
| <TAG_END: ">" > : AfterTagState
| <DECL_END: ("?>" | "!>") > : AfterTagState
| <TAG_SLASHEND: ("/>" | "/ >") > : AfterTagState

View File

@ -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("<span escape='false' attrib=\"{!call}\">${\"yes\"}</span>");
}
@Test
public void testAttributeNameWithDot() {
vf.parse("<table-row keep-together.within-page=\"always\" >");
}
@Test
public void testAttributeNameWithUnderscore() {
vf.parse("<table-row test_attribute=\"always\" >");
}
@Test
public void testAttributeNameWithColon() {
vf.parse("<table-row test:attribute=\"always\" >");
}
@Test(expected = ParseException.class)
public void testAttributeNameWithInvalidSymbol() {
vf.parse("<table-row test&attribute=\"always\" >");
}
@Test(expected = ParseException.class)
public void testAttributeNameWithInvalidDot() {
vf.parse("<table-row .class=\"always\" >");
}
@Test(expected = ParseException.class)
public void testAttributeNameWithInvalidDotV2() {
vf.parse("<table-row test..attribute=\"always\" >");
}
@Test(expected = ParseException.class)
public void testAttributeNameWithInvalidDotV3() {
vf.parse("<table-row test.attribute.=\"always\" >");
}
}

View File

@ -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