Can't copy attachment link when accessing gitea not over HTTPS #11356

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

Originally created by @OddMorning on GitHub (Jul 28, 2023).

Originally assigned to: @silverwind on GitHub.

Description

It's impossible to copy attachment link when accessing gitea over local network:

JavaScript error: Uncaught TypeError: Cannot read properties of undefined (reading 'writeText') (http://192.168.9.56:3000/assets/js/index.js?v=1.20.1 @ 54:4159).

It tries to copy text using navigator.clipboard.writeText(x) but navigator.clipboard is available only when url is either HTTPS or localhost.
There are workarounds for "insecure sources" such as document.execCommand('copy').
Or probably checking window.isSecureContext (which is true for both HTTPS and localhost) and showing a proper error message would be also fine.

Gitea Version

1.20.1

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

mstsc – 28 07 2023; 15 18 34

Git Version

No response

Operating System

No response

How are you running Gitea?

Running file gitea-1.20.1-windows-4.0-amd64.exe

Database

None

Originally created by @OddMorning on GitHub (Jul 28, 2023). Originally assigned to: @silverwind on GitHub. ### Description It's impossible to copy attachment link when accessing gitea over local network: ``` JavaScript error: Uncaught TypeError: Cannot read properties of undefined (reading 'writeText') (http://192.168.9.56:3000/assets/js/index.js?v=1.20.1 @ 54:4159). ``` It tries to copy text using `navigator.clipboard.writeText(x)` but `navigator.clipboard` is available only when url is either HTTPS or localhost. There are workarounds for "insecure sources" such as `document.execCommand('copy')`. Or probably checking `window.isSecureContext` (which is `true` for both HTTPS and localhost) and showing a proper error message would be also fine. ### Gitea Version 1.20.1 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots ![mstsc – 28 07 2023; 15 18 34](https://github.com/go-gitea/gitea/assets/12204657/fe1b7be7-5d51-4b71-84b4-530b80144e65) ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? Running file `gitea-1.20.1-windows-4.0-amd64.exe` ### Database None
GiteaMirror added the type/bug label 2025-11-02 09:35:11 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Jul 28, 2023):

IIRC it has been fixed by "Re-allow clipboard copy on non-https sites #17118"

It might be a regression of "Use clippie module to copy to clipboard #23801" @silverwind

@wxiaoguang commented on GitHub (Jul 28, 2023): IIRC it has been fixed by "Re-allow clipboard copy on non-https sites #17118" It might be a regression of "Use clippie module to copy to clipboard #23801" @silverwind
Author
Owner

@silverwind commented on GitHub (Jul 29, 2023):

Sounds like a bug in https://github.com/silverwind/clippie, I will check.

@silverwind commented on GitHub (Jul 29, 2023): Sounds like a bug in https://github.com/silverwind/clippie, I will check.
Author
Owner

@silverwind commented on GitHub (Jul 29, 2023):

Actually it was not a bug in clippie in this case, but a bare use of navigator.clipboard.writeText, which I've fixed.

@silverwind commented on GitHub (Jul 29, 2023): Actually it was not a bug in clippie in this case, but a bare use of `navigator.clipboard.writeText`, which I've fixed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11356