Uploaded image for project: 'XWiki Commons'
  1. XWiki Commons
  2. XCOMMONS-3833

Enforce the file encoding rules with Checkstyle

    XMLWordPrintable

Details

    • Unknown
    • N/A

    Description

      Following the vote at https://forum.xwiki.org/t/move-java-sources-to-utf-8-and-update-the-file-encoding-rules/18925, Java sources are UTF-8 and may contain non-ASCII characters, and properties files are ISO-8859-1.

      • Add a Checkstyle rule (in checkstyle.xml and checkstyle-test.xml) failing the build when a Java source contains an invisible or ambiguous character written raw instead of as a unicode escape: control characters, non-breaking spaces, soft hyphens, zero-width characters, bidirectional control characters and byte order marks. Such characters can't be seen in code reviews and can hide bugs or malicious code (CVE-2021-42574, "Trojan Source").
      • Add a Checkstyle rule failing the build when a properties file is encoded in UTF-8 instead of ISO-8859-1, which would display garbled characters at runtime.
      • Add an .editorconfig to commons, rendering and platform declaring these encodings, and fix the existing violations.

      Attachments

        Issue Links

          Activity

            People

              vmassol Vincent Massol
              vmassol Vincent Massol
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: