Affects PMD Version:
Make sure, to test with the latest PMD version.
Description:
Often, when an apex file contains CDATA, then if an error occurs while parsing this file with PMD... then it attempts to put the file contents in its own CDATA tag... but fails to escape the CDATA from the file.
So you end up with something like:
OPEN OPEN CLOSE CLOSE
<![CDATA[ .... <![CDATA[ .... ]]> ... ]]>
which is interpretted by xml readers as
OPEN IGNORED CLOSE ?WHAT THE?
<![CDATA[ .... <![CDATA[ .... ]]> ... ]]>
PMD Version:
PMD 7.2.0 (38bc997d4e7f4b29cee86829915f17f925211800, 2024-05-31T10:33:57Z)
Java version: 11.0.17.0.1, vendor: Azul Systems, Inc., runtime: /Users/stephen.carter/blt/tools/Darwin/jdk/openjdk_11.0.17.0.1_11.60.54_x64
Steps to reproduce:
Please provide detailed steps for how we can reproduce the bug.
pmd check -d dummy.cls -R my_ruleset.xml --format xml > output.xml
Any xml reader will crash... but we are reading the xml from within a node application. And so you can easily reproduce what we see with:
~/temp: npm install xml-js
~/temp: node
Welcome to Node.js v21.7.1.
> const { xml2js } = await import("xml-js");
undefined
> const xmlData = fs.readFileSync('./output.xml','utf-8');
undefined
> const pmdData = xml2js(xmlData, {compact: false, ignoreDeclaration: true});
Uncaught:
<ref *1> Error: Unexpected close tag
Line: 158
Column: 8
Char: >
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
CLI
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4