Unexpected rich-text copy-paste #10165

Closed
opened 2025-11-02 09:00:00 -06:00 by GiteaMirror · 9 comments
Owner

Originally created by @KN4CK3R on GitHub (Jan 27, 2023).

Copy-pasting file contents from the normal file view
grafik
results in the full markup content

<html><body>
<!--StartFragment-->

module ROME
--


<code class="code-inner"><span class="n">require</span> <span class="n">github</span><span class="p">.</span><span class="n">com</span><span class="o">/</span><span class="mi">01</span><span class="o">-</span><span class="n">edu</span><span class="o">/</span><span class="n">z01</span> <span class="n">v0</span><span class="p">.</span><span class="mf">1.0</span> <span class="o">/</span><span class="o">/</span> <span class="n">indirect</span>
</code><!--EndFragment-->
</body>
</html>

if pasted into some input fields (like the Github comment fields). Copy-pasting from Github files works as intended.

Originally created by @KN4CK3R on GitHub (Jan 27, 2023). Copy-pasting file contents from the normal file view ![grafik](https://user-images.githubusercontent.com/1666336/215104388-91fca819-9d0a-4713-b20f-6b9dc853f747.png) results in the full markup content ``` <html><body> <!--StartFragment--> module ROME -- <code class="code-inner"><span class="n">require</span> <span class="n">github</span><span class="p">.</span><span class="n">com</span><span class="o">/</span><span class="mi">01</span><span class="o">-</span><span class="n">edu</span><span class="o">/</span><span class="n">z01</span> <span class="n">v0</span><span class="p">.</span><span class="mf">1.0</span> <span class="o">/</span><span class="o">/</span> <span class="n">indirect</span> </code><!--EndFragment--> </body> </html> ``` if pasted into some input fields (like the Github comment fields). Copy-pasting from Github files works as intended.
GiteaMirror added the topic/ui label 2025-11-02 09:00:00 -06:00
Author
Owner

@silverwind commented on GitHub (Jan 27, 2023):

I don't think the source page can control what is being copied, so this behaviour to also copy rich must be some heuristics done by the browser based on the HTML tags present (likely pre plays a role).

@silverwind commented on GitHub (Jan 27, 2023): I don't think the source page can control what is being copied, so this behaviour to also copy rich must be some heuristics done by the browser based on the HTML tags present (likely `pre` plays a role).
Author
Owner

@silverwind commented on GitHub (Jan 27, 2023):

a rich-text input field (like the Github comment fields)

GitHub comment field is not rich text, it's just a <textarea>. Are you using any browser extensions that transforms it?

@silverwind commented on GitHub (Jan 27, 2023): > a rich-text input field (like the Github comment fields) GitHub comment field is not rich text, it's just a `<textarea>`. Are you using any browser extensions that transforms it?
Author
Owner

@KN4CK3R commented on GitHub (Jan 27, 2023):

No browser extension used. Wrong wording on my side. It's still unexpected if I paste the content here, it comes with the html tags.

@KN4CK3R commented on GitHub (Jan 27, 2023): No browser extension used. Wrong wording on my side. It's still unexpected if I paste the content here, it comes with the html tags.
Author
Owner

@silverwind commented on GitHub (Jan 27, 2023):

Yeah, I can reproduce with this. I think this is a bug in GitHub's paste event handling, it does not happen with a regular text area. GitHub seems to try something smart when pasting and it fails.

So we first need to know what the GitHub code tries to do.

@silverwind commented on GitHub (Jan 27, 2023): Yeah, I can reproduce [with this](https://try.gitea.io/silverwind/symlink-test/src/branch/master/package.json). I think this is a bug in GitHub's `paste` event handling, it does not happen with a regular text area. GitHub seems to try something smart when pasting and it fails. So we first need to know what the GitHub code tries to do.
Author
Owner

@silverwind commented on GitHub (Jan 27, 2023):

Checking the JS in the debugger, there are 6 paste event handlers attached. I think the most likely culprit may be https://github.com/github/paste-markdown.

@silverwind commented on GitHub (Jan 27, 2023): Checking the JS in the debugger, there are 6 `paste` event handlers attached. I think the most likely culprit may be https://github.com/github/paste-markdown.
Author
Owner

@KN4CK3R commented on GitHub (Jan 27, 2023):

If you are sure it's not Giteas fault we can close this issue. Just noticed that behaviour yesterday.

@KN4CK3R commented on GitHub (Jan 27, 2023): If you are sure it's not Giteas fault we can close this issue. Just noticed that behaviour yesterday.
Author
Owner

@silverwind commented on GitHub (Jan 27, 2023):

The bug is surely not ours, but lets keep this open for further investigation.

@silverwind commented on GitHub (Jan 27, 2023): The bug is surely not ours, but lets keep this open for further investigation.
Author
Owner

@silverwind commented on GitHub (Jan 27, 2023):

Reported it in https://github.com/github/paste-markdown/issues/80.

@silverwind commented on GitHub (Jan 27, 2023): Reported it in https://github.com/github/paste-markdown/issues/80.
Author
Owner

@silverwind commented on GitHub (Apr 3, 2023):

Closing, Github bug.

@silverwind commented on GitHub (Apr 3, 2023): Closing, Github bug.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10165