Merge branch 'pr-1869'

This commit is contained in:
Andreas Dangel
2019-07-13 19:42:55 +02:00
4 changed files with 49 additions and 5 deletions

View File

@ -29,13 +29,16 @@ Being based on a proper Antlr grammar, CPD can:
* [#1896](https://github.com/pmd/pmd/issues/1896): \[doc] Error in changelog 6.16.0 due to not properly closed rule tag
* [#1906](https://github.com/pmd/pmd/issues/1906): \[doc] Broken link for adding own CPD languages
* [#1909](https://github.com/pmd/pmd/issues/1909): \[doc] Sample usage example refers to deprecated ruleset "basic.xml" instead of "quickstart.xml"
* xml
* [#1666](https://github.com/pmd/pmd/issues/1666): \[xml] wrong cdata rule description and examples
### API Changes
### External Contributions
* [#1908](https://github.com/pmd/pmd/pull/1908): \[doc] Update ruleset filename from deprecated basic.xml to quickstart.xml - [crunsk](https://github.com/crunsk)
* [#1869](https://github.com/pmd/pmd/pull/1869): \[xml] fix #1666 wrong cdata rule description and examples - [Artem](https://github.com/KroArtem)
* [#1892](https://github.com/pmd/pmd/pull/1892): \[lua] \[cpd] Added CPD support for Lua - [Maikel Steneker](https://github.com/maikelsteneker)
* [#1908](https://github.com/pmd/pmd/pull/1908): \[doc] Update ruleset filename from deprecated basic.xml to quickstart.xml - [crunsk](https://github.com/crunsk)
{% endtocmaker %}

View File

@ -12,11 +12,11 @@ Rules to detect constructs that are either broken, extremely confusing or prone
<rule name="MistypedCDATASection"
language="xml"
since="5.0"
message="Potentialy mistyped CDATA section with extra [ at beginning or ] at the end."
message="Potentially mistyped CDATA section with extra [ at beginning or ] at the end."
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_xml_errorprone.html#mistypedcdatasection">
<description>
An XML CDATA section begins with a &lt;!CDATA[ marker, which has only one [, and ends with a ]]&gt; marker, which has only two ].
An XML CDATA section begins with a &lt;![CDATA[ marker, which has only one [, and ends with a ]]&gt; marker, which has two ].
</description>
<priority>3</priority>
<properties>
@ -30,7 +30,18 @@ An XML CDATA section begins with a &lt;!CDATA[ marker, which has only one [, and
</properties>
<example>
<![CDATA[
An extra [ looks like &lt;!CDATA[[]]&gt;, and an extra ] looks like &lt;!CDATA[]]]&gt;.
<root>
<child>
<![CDATA[[ character data ]]><![CDATA[]]]]><![CDATA[> - this cdata section is valid, but it contains an
additional square bracket at the beginning.
It should probably be just <![CDATA[ character data ]]><![CDATA[]]]]><![CDATA[>.
</child>
<child>
<![CDATA[ character data ]]]><![CDATA[]]]]><![CDATA[> - this cdata section is valid, but it contains an
additional square bracket in the end.
It should probably be just <![CDATA[ character data ]]><![CDATA[]]]]><![CDATA[>.
</child>
</root>
]]>
</example>
</rule>

View File

@ -15,6 +15,6 @@ public class PMDTaskTest extends AbstractAntTestHelper {
@Test
public void testXML() {
executeTarget("testXML");
assertOutputContaining("Potentialy mistyped CDATA section with extra [ at beginning or ] at the end.");
assertOutputContaining("Potentially mistyped CDATA section with extra [ at beginning or ] at the end.");
}
}

View File

@ -70,4 +70,34 @@
]]></code>
<source-type>xml</source-type>
</test-code>
<test-code>
<description>Example code</description>
<expected-problems>2</expected-problems>
<expected-linenumbers>3,8</expected-linenumbers>
<code><![CDATA[
<root>
<child>
<![CDATA[ character data ]]]><![CDATA[]]]]><![CDATA[> - this cdata section is valid, but it contains an
additional square bracket in the end.
It should probably be just <![CDATA[ character data ]]><![CDATA[]]]]><![CDATA[>.
</child>
<child>
<![CDATA[[ character data ]]><![CDATA[]]]]><![CDATA[> - this cdata section is valid, but it contains an
additional square bracket at the beginning.
It should probably be just <![CDATA[ character data ]]><![CDATA[]]]]><![CDATA[>.
</child>
</root>
]]></code>
</test-code>
<test-code>
<description>Square bracket at end separate by space is ok</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
<root>
<child>
<![CDATA[ character data[] ]]><![CDATA[]]]]><![CDATA[>
</child>
</root>
]]></code>
</test-code>
</test-data>