Branch: refs/heads/pmd/5.4.x
  Home:   https://github.com/pmd/pmd
  Commit: 74583d003a841af280e7fea8f3ae3521dfcbb89b
      https://github.com/pmd/pmd/commit/74583d003a841af280e7fea8f3ae3521dfcbb89b
  Author: pyxide <[email protected]>
  Date:   2017-01-10 (Tue, 10 Jan 2017)

  Changed paths:
    M pmd-core/src/main/java/net/sourceforge/pmd/ant/Formatter.java

  Log Message:
  -----------
  Ant Task Formatter encoding issue with XMLRenderer

Hi,

The writers in the Ant task's formatter uses the default platform's encoding 
(for instance cp1252 on Western Windows) and the XMLRenderer sets the default 
XML encoding to UTF-8. This may lead to incorrect XML encoding, detected for 
instance when the XML file is sent to a XSLT task.
This goes undetected as long as the characters in the XML file are in the ASCII 
subset, which is frequently the case with code, usually in plain Latin 
language. In my case, the issue was raised because of the localized formatting 
of some line numbers greater than 999, due to localized thousand separator 
0xA0, which is out of the ASCII subset.

I modified the Formatter class to always use a charset for writers. When no 
encoding is specified, UTF-8 is used instead of the default platform's encoding.

I strongly recommend to *always set the encoding parameter* of the formatter 
element. It should be reflected as so in the Ant Task documentation.

```xml
<pmd encoding="cp1252"> <!-- source encoding -->
  <formatter type="xml" toFile="pmd.xml">
    <param name="encoding" value="UTF-8" /> <!-- report encoding -->
  </formatter>
  <fileset dir="src/main/java">
    <include name="**/*.java"/>
  </fileset>
</pmd>
```
Note: when digging into sourceforge issues for similar bugs, I found [Bug 877: 
Output with encoding CP1252](https://sourceforge.net/p/pmd/bugs/877/) . Not the 
same task, but the same symptoms, probably the same cause ?


  Commit: 368313fd8f246300b6f38159029f217b1eedaef0
      https://github.com/pmd/pmd/commit/368313fd8f246300b6f38159029f217b1eedaef0
  Author: pyxide <[email protected]>
  Date:   2017-01-10 (Tue, 10 Jan 2017)

  Changed paths:
    M pmd-core/src/main/java/net/sourceforge/pmd/ant/Formatter.java

  Log Message:
  -----------
  Update Formatter.java


  Commit: 4c71b0da4ad11049d01aa5c2e10292711cf7b5dc
      https://github.com/pmd/pmd/commit/4c71b0da4ad11049d01aa5c2e10292711cf7b5dc
  Author: pyxide <[email protected]>
  Date:   2017-01-10 (Tue, 10 Jan 2017)

  Changed paths:
    M pmd-core/src/main/java/net/sourceforge/pmd/ant/Formatter.java

  Log Message:
  -----------
  checkstyle fixes


  Commit: abf65acb63522a6332020821efef7c275bec275c
      https://github.com/pmd/pmd/commit/abf65acb63522a6332020821efef7c275bec275c
  Author: pyxide <[email protected]>
  Date:   2017-01-10 (Tue, 10 Jan 2017)

  Changed paths:
    M pmd-core/src/main/java/net/sourceforge/pmd/ant/Formatter.java

  Log Message:
  -----------
  Bug fix and enhanced console output encoding

- due to some rewriting without testing, the encoding property was not added to 
the renderer properties.
- better console encoding: use system property `sun.stdout.encoding` in 
interactive console, and `file.encoding` in piped or redirected output


  Commit: 89600bfcc4e7d75f67bfbeb77dc04865c8355921
      https://github.com/pmd/pmd/commit/89600bfcc4e7d75f67bfbeb77dc04865c8355921
  Author: pyxide <[email protected]>
  Date:   2017-01-10 (Tue, 10 Jan 2017)

  Changed paths:
    M pmd-core/src/main/java/net/sourceforge/pmd/ant/Formatter.java

  Log Message:
  -----------
  checkstyle fixes


  Commit: 958f8df5f557a381e556818f156bc03b981dfed8
      https://github.com/pmd/pmd/commit/958f8df5f557a381e556818f156bc03b981dfed8
  Author: pyxide <[email protected]>
  Date:   2017-01-10 (Tue, 10 Jan 2017)

  Changed paths:
    M pmd-core/src/main/java/net/sourceforge/pmd/ant/Formatter.java

  Log Message:
  -----------
  Reflection detection code for console encoding

Note: calling the static native method `String Console.encoding()` returns the 
current console encoding, even if `System.console()` is null because the 
console is not interactive (pipe or redirection).


  Commit: d7c503bee4209ac3ae4359c45c1d8db2ee8694db
      https://github.com/pmd/pmd/commit/d7c503bee4209ac3ae4359c45c1d8db2ee8694db
  Author: pyxide <[email protected]>
  Date:   2017-01-10 (Tue, 10 Jan 2017)

  Changed paths:
    M pmd-core/src/main/java/net/sourceforge/pmd/ant/Formatter.java

  Log Message:
  -----------
  checkstyle fixes


  Commit: 43a38d314433e6f4f1345d793cb418157849765c
      https://github.com/pmd/pmd/commit/43a38d314433e6f4f1345d793cb418157849765c
  Author: pyxide <[email protected]>
  Date:   2017-01-10 (Tue, 10 Jan 2017)

  Changed paths:
    M pmd-core/src/main/java/net/sourceforge/pmd/ant/Formatter.java

  Log Message:
  -----------
  Console encoding only when interactive


  Commit: 60c329b07a1a50c5bd959fe4bfed0886bad6c50f
      https://github.com/pmd/pmd/commit/60c329b07a1a50c5bd959fe4bfed0886bad6c50f
  Author: Juan Martín Sotuyo Dodero <[email protected]>
  Date:   2017-01-10 (Tue, 10 Jan 2017)

  Changed paths:
    M pmd-core/src/main/java/net/sourceforge/pmd/ant/Formatter.java

  Log Message:
  -----------
  Merge branch 'pr-170' into pmd/5.4.x


Compare: https://github.com/pmd/pmd/compare/b9e5901b123e...60c329b07a1a
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Pmd-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pmd-commits

Reply via email to