problems with copying CRLF files in the browser #764

Closed
opened 2025-11-02 03:35:39 -06:00 by GiteaMirror · 8 comments
Owner

Originally created by @mrexodia on GitHub (Jun 2, 2017).

  • Gitea version (or commit ref): 62f600c
  • Git version: ?
  • Operating system: Windows 8.1 x64
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

When copying a file with CRLF line endings (https://try.gitea.io/mrexodia/testcopy/src/master/crlf.txt) there will be additional lines inserted when pasting in notepad:

Originally created by @mrexodia on GitHub (Jun 2, 2017). - Gitea version (or commit ref): 62f600c - Git version: ? - Operating system: Windows 8.1 x64 - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x] Yes (provide example URL) - [ ] No - [ ] Not relevant When copying a file with CRLF line endings (https://try.gitea.io/mrexodia/testcopy/src/master/crlf.txt) there will be additional lines inserted when pasting in notepad: ![](https://i.imgur.com/mJ4zqU9.png)
GiteaMirror added the type/bug label 2025-11-02 03:35:39 -06:00
Author
Owner

@silverwind commented on GitHub (Jun 3, 2017):

This is because of empty text nodes inside the code <pre>:

<ol class="linenums"><li class="L1" rel="L1">Lorem ipsum dolor sit amet
</li>
<li class="L2" rel="L2">Nam condimentum, odio a egestas dapibus
</li>
<li class="L3" rel="L3">Nulla egestas velit nec elit dapibus aliquet.
</li>
<li class="L4" rel="L4">Nulla facilisi. Praesent vel sem sit amet
</li>
<li class="L5" rel="L5">Fusce tincidunt laoreet laoreet.</li>
</ol>

Fix would be to render </li><li (e.g. no newline between)

@silverwind commented on GitHub (Jun 3, 2017): This is because of empty text nodes inside the code `<pre>`: ````html <ol class="linenums"><li class="L1" rel="L1">Lorem ipsum dolor sit amet </li> <li class="L2" rel="L2">Nam condimentum, odio a egestas dapibus </li> <li class="L3" rel="L3">Nulla egestas velit nec elit dapibus aliquet. </li> <li class="L4" rel="L4">Nulla facilisi. Praesent vel sem sit amet </li> <li class="L5" rel="L5">Fusce tincidunt laoreet laoreet.</li> </ol> ```` Fix would be to render `</li><li` (e.g. no newline between)
Author
Owner

@mrexodia commented on GitHub (Jun 10, 2017):

The same issue was fixed in gogs by simply trimming \r from the end of every line: 91f65cedc8

@mrexodia commented on GitHub (Jun 10, 2017): The same issue was fixed in gogs by simply trimming `\r` from the end of every line: https://github.com/gogits/gogs/commit/91f65cedc88729b5504d72647185d685083df773
Author
Owner

@appleboy commented on GitHub (Jun 10, 2017):

@mrexodia fixed in https://github.com/go-gitea/gitea/pull/1931

@appleboy commented on GitHub (Jun 10, 2017): @mrexodia fixed in https://github.com/go-gitea/gitea/pull/1931
Author
Owner

@mrexodia commented on GitHub (Jun 10, 2017):

Yeah, but that's not merged 😄

@mrexodia commented on GitHub (Jun 10, 2017): Yeah, but that's not merged 😄
Author
Owner

@silverwind commented on GitHub (Jun 10, 2017):

Soon. I'd say my approach is the better one, it preserves the original line endings and does not introduce a extra \n at the end of the copied text.

@silverwind commented on GitHub (Jun 10, 2017): Soon. I'd say my approach is the better one, it preserves the original line endings and does not introduce a extra `\n` at the end of the copied text.
Author
Owner

@mrexodia commented on GitHub (Jun 10, 2017):

From what I can tell no new lines were introduced if I copy from here: https://try.gogs.io/mrexodia/testcopy/src/master/crlf.txt

I'm still looking at switching to gitea, but I couldn't really find a list of benefits or a clear update path from gogs so I'm postponing it...

@mrexodia commented on GitHub (Jun 10, 2017): From what I can tell no new lines were introduced if I copy from here: https://try.gogs.io/mrexodia/testcopy/src/master/crlf.txt I'm still looking at switching to gitea, but I couldn't really find a list of benefits or a clear update path from gogs so I'm postponing it...
Author
Owner

@silverwind commented on GitHub (Jun 10, 2017):

Might be your editor trimming it, but I certainly get a newline pasted after the text:

@silverwind commented on GitHub (Jun 10, 2017): Might be your editor trimming it, but I certainly get a newline pasted after the text: <img width="495" src="https://user-images.githubusercontent.com/115237/27006490-1b26b600-4e35-11e7-99ac-b6c88ef2162a.png">
Author
Owner

@lafriks commented on GitHub (Jun 10, 2017):

@mrexodia Upgrade instructions are here - https://docs.gitea.io/en-us/upgrade-from-gogs/

@lafriks commented on GitHub (Jun 10, 2017): @mrexodia Upgrade instructions are here - https://docs.gitea.io/en-us/upgrade-from-gogs/
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#764