Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
OddMorning opened this issue Jul 28, 2023 · 3 comments · Fixed by #26224
Closed

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

OddMorning opened this issue Jul 28, 2023 · 3 comments · Fixed by #26224
Assignees
Labels
Milestone

Comments

@OddMorning
Copy link

OddMorning commented Jul 28, 2023

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

@wxiaoguang
Copy link
Contributor

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

@silverwind
Copy link
Member

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

@silverwind
Copy link
Member

silverwind commented 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.

@lunny lunny added this to the 1.20.3 milestone Jul 29, 2023
silverwind added a commit that referenced this issue Jul 29, 2023
Fixes: #26202

Actually later I found out the code did not use `clippie`, so I fixed
it. The bug was never in the clippie module like I initially suspected.
Also, I added a tooltip for feedback.

<img width="139" alt="image"
src="https://github.com/go-gitea/gitea/assets/115237/da501670-9c15-4412-969a-b559773c7ab9">

---------

Co-authored-by: Giteabot <teabot@gitea.io>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants