Uploaded image for project: 'Bitbucket Data Center'
  1. Bitbucket Data Center
  2. BSERV-10542

In-browser editor replace the eol at the end of file with LF regardless of existing eol type

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Low Low
    • 5.8.0
    • 5.5.5
    • None
    • None

      Summary

      Bitbucket Server in-browser editor unexpectedly replaces CRLF at the end of file with LF.

      Environment

      • Bitbucket Server 4.13 or newer versions
        • Verified with v5.5.5 hosted on Ubuntu 14.04.5 LTS and Git version 2.13.0

      Steps to Reproduce

      1. (Local) Create a file containing lines with CRLF
        # The special character "\r\n" stands for CRLF. And "\c" suppresses newline
        $ echo -e "North\r\nSouth\r\nWest\r\n\c" > example.txt
        # Verify the file ends with "^M$"
        $ cat -e example.txt
        North^M$
        South^M$
        West^M$
        # Verify the file ends with "0d 0a" in hexadecimal binary
        $ hexdump -C example.txt
        00000000  4e 6f 72 74 68 0d 0a 53  6f 75 74 68 0d 0a 57 65  |North..South..We|
        00000010  73 74 0d 0a                                       |st..|
        00000014
        
      1. (Local) Git commit and push the file to Bitbucket Server
      2. (Remote) Open example.txt and add "East" to the second line by in-browser editor
      3. (Local) Git pull
      4. (Local) Check the eol type at end of file is changed to LF from CRLF
        # Verify the file ends with "$" but not "^M$"
        $ cat -e example.txt
        North^M$
        East^M$
        South^M$
        West$
        # Now the file ends with "0a" in hexadecimal binary
        $ hexdump -C example.txt
        00000000  4e 6f 72 74 68 0d 0a 45  61 73 74 0d 0a 53 6f 75  |North..East..Sou|
        00000010  74 68 0d 0a 57 65 73 74  0a                       |th..West.|
        00000019
        

      Expected Results

      The edited file keeps CRLF at the end of file:

      $ cat -e example.txt
      North^M$
      East^M$
      South^M$
      West^M$
      

      Actual Results

      CRLF at the end of file is replaced with LF.

      $ cat -e example.txt
      North^M$
      East^M$
      South^M$
      West$
      

      Notes

      • Owing to these configurations in git, other lines except the end of file are intact
      • In-browser editor inserts newline (LF) when the file doesn't contain eol character
        echo 'Foo\c' > example.txt
        

      Workaround

      • Edit files in other editor but not in-browser editor if you want to keep CRLF

            [BSERV-10542] In-browser editor replace the eol at the end of file with LF regardless of existing eol type

            No work has yet been logged on this issue.

              mmcglynn Michael McGlynn (Inactive)
              kyamamoto@atlassian.com K. Yamamoto
              Affected customers:
              2 This affects my team
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: