Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-38121

Patch file processing does not support UTF-8 encoding

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • patch-parameter-plugin
    • None
    • * Jenkins 1.598
      * patch-parameter plugin V1.2
      * diff4j-1.2 from https://github.com/cloudbees/diff4j (7f212fe6f891e8eaaa349ed9fc6866c9d1280dd2)
      * GNU patch 2.7.5
      * SVN 1.9

      I'm having problem with a patch file that changes a code comment using "’" (RIGHT SINGLE QUOTATION MARK, UTF-8 U+2019 encoded as 0xE2 0x80 0x99) into the (normal?) apostrophe "'" (APOSTROPHE, ASCII 39/0x27). The patch is created with SVN diff (V1.9) in Linux and can be used fine with GNU patch 2.7.5. However, when uploading the patch to jenkins, it can't be applies- The error is

      com.cloudbees.diff.PatchException: Cannot apply hunk @@ 245
      

      I've debugged the issue using diff4j-1.2 (7f212fe6f891e8eaaa349ed9fc6866c9d1280dd2) from https://github.com/cloudbees/diff4j in a test java application. Adding some printouts in

      com/cloudbees/diff/ContextualPatch.java
      private boolean applyHunk(...)
      ...
      if (!targetLine.equals(hunkLine.substring(1).trim())) { // be optimistic, compare trimmed context lines
          System.out.println("hunk: "+hunkLine);
          System.out.println("target: "+targetLine);
      

      where tries to compare lines, I get this:

      hunk: - // this commentâ<U+0080><U+0099>s encoding fails
      target: // this comment’s encoding fails
      

      Seems Java does not consider the patch file's line as UTF-8, but the source code's line is taken as UTF-8.

            Unassigned Unassigned
            axelh Axel Heider
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: