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 * [#2764](https://github.com/pmd/pmd/issues/2764): \[java] CloseResourceRule does not recognize multiple assignment done to resource
* miscellaneous * miscellaneous
* [#2823](https://github.com/pmd/pmd/issues/2823): \[doc] Renamed/Moved rules are missing in documentation * [#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 ### 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) * [#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) * [#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) * [#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 %} {% endtocmaker %}

View File

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

View File

@ -6,6 +6,8 @@ package net.sourceforge.pmd.lang.vf.ast;
import org.junit.Test; import org.junit.Test;
import net.sourceforge.pmd.lang.ast.ParseException;
/** /**
* @author sergey.gorbaty * @author sergey.gorbaty
*/ */
@ -26,4 +28,39 @@ public class VfParserTest extends AbstractVfNodesTest {
vf.parse("<span escape='false' attrib=\"{!call}\">${\"yes\"}</span>"); 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 [Image] or [Truncated image[ Bcol Ecol
L1 L1
[24] 1 1 [25] 1 1
[85] 2 10 [86] 2 10
[88] 11 11 [89] 11 11
L2 L2
[24] 2 2 [25] 2 2
[85] 3 6 [86] 3 6
[87] 8 10 [88] 8 10
[91] 11 11 [92] 11 11
[94] 12 12 [95] 12 12
[105] 13 22 [106] 13 22
[103] 23 23 [104] 23 23
[87] 25 28 [88] 25 28
[91] 29 29 [92] 29 29
[94] 30 30 [95] 30 30
[105] 31 38 [106] 31 38
[103] 39 39 [104] 39 39
[87] 41 44 [88] 41 44
[91] 45 45 [92] 45 45
[94] 46 46 [95] 46 46
[104] 47 48 [105] 47 48
[66] 49 57 [67] 49 57
[41] 58 58 [42] 58 58
[66] 59 67 [67] 59 67
[73] 68 68 [74] 68 68
[105] 69 69 [106] 69 69
[104] 70 71 [105] 70 71
[66] 72 81 [67] 72 81
[73] 82 82 [74] 82 82
[103] 83 83 [104] 83 83
[87] 85 86 [88] 85 86
[91] 87 87 [92] 87 87
[94] 88 88 [95] 88 88
[105] 89 99 [106] 89 99
[103] 100 100 [104] 100 100
[90] 101 102 [91] 101 102
L3 L3
[25] 1 2 [26] 1 2
[85] 3 11 [86] 3 11
[88] 12 12 [89] 12 12
EOF EOF